update book code

This commit is contained in:
Unknwon
2015-03-03 12:25:25 -05:00
parent b8c82ba4e5
commit eab1d98ba8
465 changed files with 15392 additions and 1572 deletions

View File

@@ -0,0 +1,34 @@
// recover_divbyzero.go
package main
import (
"fmt"
)
func badCall() {
a, b := 10, 0
n := a / b
fmt.Println(n)
}
func test() {
defer func() {
if e := recover(); e != nil {
fmt.Printf("Panicing %s\r\n", e);
}
}()
badCall()
fmt.Printf("After bad call\r\n");
}
func main() {
fmt.Printf("Calling test\r\n");
test()
fmt.Printf("Test completed\r\n");
}
/* Output:
Calling test
Panicing runtime error: integer divide by zero
Test completed
*/