- package main
-
- import (
- "fmt"
- )
-
- func test() int {
- defer func() {
- err := recover()
- if err != nil {
- fmt.Println(err)
- }
- }()
- var a int = 10
- var b int = 0
- return a/b
- }
-
- func main() {
- res := test()
-
- fmt.Println(res)
- fmt.Println("这里是否执行")
- }