Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardGodefer panic recover mechanicsSingle-choice MCQ

What does the following snippet print, and why, given how recover interacts with the defer call stack?

func safe() { defer func() { if r := recover(); r != nil { fmt.Println("recovered:", r) } }() panic("boom") } func main() { safe() fmt.Println("after") }