go异常处理

一。defer

      1. Go 语言提供了关键字 来在函数运行结束的时候运行一段代码或调用一个 清理函数

      2.

二。panic和recover

     

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")
}
原文地址:https://www.cnblogs.com/derekchen/p/9740946.html