doc panic

This commit is contained in:
Mark McGranaghan 2012-09-20 19:52:18 -07:00
parent 846892538e
commit 37e21909a5

View File

@ -1,8 +1,21 @@
// Panic
// A `panic` means something went unexpectedly wrong.
// Mostly we use it to fail fast on errors that
// shouldn't occur during normal operation.
package main
import "fmt"
func main() {
panic("O noes")
fmt.Println("Finished")
}
panic("O noes") // We'll use panic throught this book to check for
} // unexpected errors. This is the only program in the
// book designed to panic.
/*
$ go run 26-panic.go
panic: O noes
goroutine 1 [running]:
main.main()
/.../src/26-panic.go:4 +0x47
...
*/