Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
33 lines (23 sloc) 864 Bytes
Title: 65.Exit.go
Author: OpenSource
Date: 2017-05-23
Description: For Study
Use os.Exit to immediately exit with a given status.
package main
import "fmt"
import "os"
func main(){
defer fmt.Println("defer !! print !!!!!!!!!")
// defers will not be run when using os.Exit, so this fmt.Println will never be called.
// Exit with status 3.
// Note that unlike e.g. C, Go does not use an integer return value
// from main to indicate exit status.
// If you’d like to exit with a non-zero status you should use os.Exit.
// If you run exit.go using go run, the exit will be picked up by go and printed.
// By building and executing a binary you can see the status in the terminal.
You can’t perform that action at this time.