This commit is contained in:
Mark McGranaghan
2012-09-23 14:31:05 -07:00
parent d1e82077ac
commit 64aa4acf05
69 changed files with 1 additions and 1 deletions

16
069-exit/exit.go Normal file
View File

@@ -0,0 +1,16 @@
// Exit
package main
// Use `os.Exit` to immediatly exit with a given
// status.
import "os"
func main() {
// This `println` will never be reached because the
// exit is immediate.
defer println("!")
os.Exit(3)
}
// todo: discuss building before getting here

11
069-exit/exit.sh Normal file
View File

@@ -0,0 +1,11 @@
# If you run `exit.go` using `go run`, the exit
# will be picked up by `go` and printed.
$ go run exit.go
exit status 3
# By building and executing a binary you can see
# the status in the terminal.
$ go build exit.go
$ ./exit
$ echo $?
3