Debian Codegraph @

quickfix/qf1002/testdata/go1.0/CheckTaglessSwitch/CheckTaglessSwitch.go.golden

raw
1 package pkg
2
3 func foo() int { return 0 }
4
5 func fn1() {
6 var x, y int
7 var z map[string][]int
8 var a bool
9
10 switch x { //@ diag(`could use tagged switch on x`)
11 case 4: // comment
12 case 1, 2, 3:
13 }
14
15 switch x { //@ diag(`could use tagged switch on x`)
16 case 1, 2, 3:
17 case 4:
18 default:
19 }
20
21 switch z[""][0] { //@ diag(`could use tagged switch on z[""][0]`)
22 case 1, 2:
23 }
24
25 switch a { //@ diag(`could use tagged switch on a`)
26 case x == y, x != y:
27 }
28
29 switch {
30 case z[""][0] == 1 || z[""][1] == 2:
31 }
32
33 switch {
34 case x == 1 || x == 2, y == 3:
35 case x == 4:
36 default:
37 }
38
39 switch {
40 case x == 1 || x == 2, x == 3:
41 case y == 4:
42 }
43
44 switch {
45 case x == 1 || x == 2, x == foo():
46 case x == 4:
47 default:
48 }
49
50 switch {
51 }
52
53 switch {
54 default:
55 }
56
57 switch {
58 case x == 1 && x == 2:
59 }
60
61 switch b := 42; b { //@ diag(`could use tagged switch on b`)
62 case 0:
63 case 1:
64 default:
65 _ = b
66 }
67 }