1. package main
    2. import "fmt"
    3. func badCall() {
    4. panic("bad end")
    5. }
    6. func test() {
    7. defer func() {
    8. if e := recover(); e != nil {
    9. fmt.Printf("Panicing %s\r\n", e)
    10. }
    11. }()
    12. badCall()
    13. fmt.Printf("After bad call\r\n")
    14. }
    15. func main() {
    16. fmt.Printf("Calling test\r\n")
    17. test()
    18. fmt.Printf("Test completed\r\n")
    19. }
    20. Calling test
    21. Panicing bad end
    22. Test completed