doc panic
This commit is contained in:
parent
846892538e
commit
37e21909a5
@ -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
|
package main
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
panic("O noes")
|
panic("O noes") // We'll use panic throught this book to check for
|
||||||
fmt.Println("Finished")
|
} // 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
|
||||||
|
...
|
||||||
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user