func test_1(){exit:=make(chan struct{})
go func() {
defer close(exit)
defer println("exit") func(){
defer func() {
println("b:",recover()==nil,recover())
}() func (){
println("c") //runtime.Goexit()
panic("panic done")
println("c done")
}()
println("b done")
}()
println("a done")
}()
<-exit}調(diào)用panic后會結(jié)束后續(xù)的流程,defer可以繼續(xù)執(zhí)行,但是println("a done")還是輸出了了結(jié)果,照理來說panic調(diào)用后這部分應(yīng)該也不能輸出的為啥能輸出“a done”?
go panic結(jié)束流程
慕無忌1623718
2018-09-23 10:46:57