go 异常处理

package main

import "fmt"

func main() {
    defer func() {
        if err := recover(); err != nil {
            fmt.Println(err)
        }
    }()
    defer func() {
        panic("three")
    }()
    defer func() {
        panic("two")
    }()
    panic("one")
}

输出

three

猜你喜欢

转载自www.cnblogs.com/sea-stream/p/10333242.html