gobyexample/054-exit.go
Mark McGranaghan 354a9d862f reorder
2012-09-21 07:54:20 -07:00

22 lines
580 B
Go

package main // Use `os.Exit` to immediatly exit with a given
// status.
import "os"
func main() {
defer println("!") // This `println` will never be reached.
os.Exit(3)
}
/*
$ go run exit.go // If you run `exit.go` using `go run`, the exit
exit status 3 // will be picked up by `go` and printed.
$ go build exit.go // By building and executing a binary you can see
$ ./exit // the status in the terminal
$ echo $?
3
*/
// == todo
// discuss building before getting here