Hi, group. Recently I found an issue in our product, panic can't be recoved in some situation, I spend some time on it.
Please find following simple Test function, I don't understand why logPanic function cant' catch the panic, but call recover directly can do that. package main import ( "fmt" "sync" "testing" ) var ( groups = &sync.WaitGroup{} ) func logPanic() { if err := recover(); err != nil { fmt.Println("got panic") return } } func DoTask() { DoTask1Panic() groups.Wait() } func DoTask1Panic() { groups.Add(1) go func() { defer func() { * // logPanic can't recover from panic here* logPanic() // But can recover from here // if err := recover(); err != nil { // fmt.Println(err) // } groups.Done() }() panic("panic") }() } func TestPanic(t *testing.T) { DoTask() fmt.Println("Done") } -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/6b9eb342-a722-4af0-a12b-dcf65a0d2312%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.