Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumGosync.Once and sync.PoolSingle-choice MCQ

What happens if the function passed to sync.Once.Do panics, and Do is later called again with a different function?

var once sync.Once func init1() { panic("boom") } func init2() { fmt.Println("ran init2") } func main() { func() { defer func() { recover() }() once.Do(init1) // panics }() once.Do(init2) // what here? }