首页 > TAG信息列表 > recoverFromPanic

[Go] Defer, panic, recover

package main import ( "fmt" ) func recoverFromPanic() { fmt.Println("defer") } func doThings() { defer recoverFromPanic() for i := 0; i < 5; i++ { fmt.Println(i) if i == 2 { panic("NOT 2") // If there is a pa