package main
2
3 import(
4 "fmt"
5
6 )
7
8
9 func catch(){
10
11 if err := recover(); err != nil {
12 fmt.Println(err)
13 }
14
15 }
16
17 func checkErr(err error){
18 if err != nil{
19 panic(err)
20 }
21
22 }
23
24 func test(){
25 defer catch()
26 var a int =10
27 var b int = 10
28 var c int
29 c =a/(b-a)
30 fmt.Println(c)
31 }
32
33 func main(){
34
35 test()
36 print("process is over\n");
37
38 }
有疑问加站长微信联系(非本文作者)