recover.go
package main import "fmt" func myPanic() { panic("a problem")}func main() { defer func() { if r := recover(); r != nil { fmt.Println("recovered. Error:\n", r) } }() myPanic() fmt.Println("After myPanic()")}
京公网安备 11010502049817号