同步等待 panic defer
package main import( "fmt" ) func main(){ // fmt.Println("Hello World") defer_all() } func defer_all(){ defer func(){ fmt.Println("打印前") }() defer func(){ fmt.Println("打印中") }() defer func(){ fmt.Println("打印后") }() panic("触发异常") }
2024-03-22 22:02:16
同步等待 panic defer
package main import( "fmt" ) func main(){ // fmt.Println("Hello World") defer_all() } func defer_all(){ defer func(){ fmt.Println("打印前") }() defer func(){ fmt.Println("打印中") }() defer func(){ fmt.Println("打印后") }() panic("触发异常") }