Panic 和 Recover
package main
import (
"fmt"
)
func a() {
fmt.Println("Inside a()")
defer func() {
if c := recover(); c != nil {
fmt.Println("Recover inside a()!")
}
}()
fmt.Println("About to call b()")
b()
fmt.Println("b() exited!")
fmt.Println("Exiting a()")
}Last updated