lean into examples
This commit is contained in:
11
examples/panic/panic.go
Normal file
11
examples/panic/panic.go
Normal file
@@ -0,0 +1,11 @@
|
||||
// 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
|
||||
|
||||
func main() {
|
||||
// We'll use panic throught this book to check for
|
||||
// unexpected errors. This is the only program in the
|
||||
// book designed to panic.
|
||||
panic("O noes")
|
||||
}
|
||||
7
examples/panic/panic.sh
Normal file
7
examples/panic/panic.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
$ go run 26-panic.go
|
||||
panic: O noes
|
||||
|
||||
goroutine 1 [running]:
|
||||
main.main()
|
||||
/.../src/26-panic.go:4 +0x47
|
||||
...
|
||||
Reference in New Issue
Block a user