package main import ( "fmt" ) var( h = 11 ) func main() { fmt.Println("start main function.") defer func () { fmt.Println("my defer to func.") if err := recover(); err != nil { fmt.Println(err) return } fmt.Println("func m") }() showErr() fmt.Println("main m.") } func showErr(){ if h != 10 { panic("h not = 10") } fmt.Println("h ------> ", h) }