Go语言宕机恢复(recover)——防止程序崩溃

package main

import (
"fmt"
)

func RE() {
defer func() {
err:= recover()
if err != nil{
fmt.Println(err)
}

}()

func() {
panic("fsdfsdf")
}()

}
func main() {
RE()
fmt.Println("fsdfs")
}

更多具体细节http://c.biancheng.net/view/64.html
原文地址:https://www.cnblogs.com/cheyunhua/p/14759156.html