一。defer函數
1. Go 語言提供了關鍵字 來在函數運行結束的時候運行一段代碼或調用一個 清理函數spa
2.code
二。panic和recoverblog
package main import ( "fmt" ) func main() { defer func() { msg := recover() fmt.Println(msg) }() fmt.Println("I am walking and singing...") panic("It starts to rain cats and dogs") }