Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / honnef.co / go / tools@v0.0.1-2020.1.5 / unused / testdata / src / fields / fields.go
1 // Test of field usage detection
2
3 package pkg
4
5 type t1 struct{ f11, f12 int }
6 type t2 struct{ f21, f22 int }
7 type t3 struct{ f31 t4 }
8 type t4 struct{ f41 int }
9 type t5 struct{ f51 int }
10 type t6 struct{ f61 int }
11 type t7 struct{ f71 int }
12 type m1 map[string]t7
13 type t8 struct{ f81 int }
14 type t9 struct{ f91 int }
15 type t10 struct{ f101 int }
16 type t11 struct{ f111 int }
17 type s1 []t11
18 type t12 struct{ f121 int }
19 type s2 []t12
20 type t13 struct{ f131 int }
21 type t14 struct{ f141 int }
22 type a1 [1]t14
23 type t15 struct{ f151 int }
24 type a2 [1]t15
25 type t16 struct{ f161 int }
26 type t17 struct{ f171, f172 int }       // want `t17`
27 type t18 struct{ f181, f182, f183 int } // want `f182` `f183`
28
29 type t19 struct{ f191 int }
30 type m2 map[string]t19
31
32 type t20 struct{ f201 int }
33 type m3 map[string]t20
34
35 type t21 struct{ f211, f212 int } // want `f211`
36
37 func foo() {
38         _ = t10{1}
39         _ = t21{f212: 1}
40         _ = []t1{{1, 2}}
41         _ = t2{1, 2}
42         _ = []struct{ a int }{{1}}
43
44         // XXX
45         // _ = []struct{ foo struct{ bar int } }{{struct{ bar int }{1}}}
46
47         _ = []t1{t1{1, 2}}
48         _ = []t3{{t4{1}}}
49         _ = map[string]t5{"a": {1}}
50         _ = map[t6]string{{1}: "a"}
51         _ = m1{"a": {1}}
52         _ = map[t8]t8{{}: {1}}
53         _ = map[t9]t9{{1}: {}}
54         _ = s1{{1}}
55         _ = s2{2: {1}}
56         _ = [...]t13{{1}}
57         _ = a1{{1}}
58         _ = a2{0: {1}}
59         _ = map[[1]t16]int{{{1}}: 1}
60         y := struct{ x int }{}
61         _ = y
62         _ = t18{f181: 1}
63         _ = []m2{{"a": {1}}}
64         _ = [][]m3{{{"a": {1}}}}
65 }
66
67 func init() { foo() }