Source file
test/defererrcheck.go
1
2
3
4
5
6
7
8
9 package main
10
11 import "fmt"
12
13 var glob = 3
14
15 func f1() {
16
17 for i := 0; i < 10; i++ {
18 fmt.Println("loop")
19 }
20 defer func() {
21 fmt.Println("defer")
22 }()
23 }
24
25 func f2() {
26 for {
27 defer func() {
28 fmt.Println("defer1")
29 }()
30 if glob > 2 {
31 break
32 }
33 }
34 defer func() {
35 fmt.Println("defer2")
36 }()
37 }
38
39 func f3() {
40 defer func() {
41 fmt.Println("defer2")
42 }()
43 for {
44 defer func() {
45 fmt.Println("defer1")
46 }()
47 if glob > 2 {
48 break
49 }
50 }
51 }
52
53 func f4() {
54 defer func() {
55 fmt.Println("defer")
56 }()
57 label:
58 fmt.Println("goto loop")
59 if glob > 2 {
60 goto label
61 }
62 }
63
64 func f5() {
65 label:
66 fmt.Println("goto loop")
67 defer func() {
68 fmt.Println("defer")
69 }()
70 if glob > 2 {
71 goto label
72 }
73 }
74
75 func f6() {
76 label:
77 fmt.Println("goto loop")
78 if glob > 2 {
79 goto label
80 }
81
82
83 defer func() {
84 fmt.Println("defer")
85 }()
86 }
87
View as plain text