github.com/amarpal/go-tools@v0.0.0-20240422043104-40142f59f616/unused/testdata/src/example.com/embedding/embedding.go (about) 1 package pkg 2 3 type I interface { //@ used("I", true) 4 f1() //@ used("f1", true) 5 f2() //@ used("f2", true) 6 } 7 8 func init() { //@ used("init", true) 9 var _ I //@ used("_", true) 10 } 11 12 type t1 struct{} //@ used("t1", true) 13 type T2 struct { //@ used("T2", true) 14 t1 //@ used("t1", true) 15 } 16 17 func (t1) f1() {} //@ used("f1", true) 18 func (T2) f2() {} //@ used("f2", true) 19 20 func Fn() { //@ used("Fn", true) 21 var v T2 //@ used("v", true) 22 _ = v.t1 23 } 24 25 type I2 interface { //@ used("I2", true) 26 f3() //@ used("f3", true) 27 f4() //@ used("f4", true) 28 } 29 30 type t3 struct{} //@ used("t3", true) 31 type t4 struct { //@ used("t4", true) 32 x int //@ used("x", false) 33 y int //@ used("y", false) 34 t3 //@ used("t3", true) 35 } 36 37 func (*t3) f3() {} //@ used("f3", true) 38 func (*t4) f4() {} //@ used("f4", true) 39 40 func init() { //@ used("init", true) 41 var i I2 = &t4{} //@ used("i", true) 42 i.f3() 43 i.f4() 44 } 45 46 type i3 interface { //@ used("i3", true) 47 F() //@ used("F", true) 48 } 49 50 type I4 interface { //@ used("I4", true) 51 i3 52 } 53 54 type T5 struct { //@ used("T5", true) 55 t6 //@ used("t6", true) 56 } 57 58 type t6 struct { //@ used("t6", true) 59 F int //@ used("F", true) 60 } 61 62 type t7 struct { //@ used("t7", true) 63 X int //@ used("X", true) 64 } 65 type t8 struct { //@ used("t8", true) 66 t7 //@ used("t7", true) 67 } 68 type t9 struct { //@ used("t9", true) 69 t8 //@ used("t8", true) 70 } 71 72 var _ = t9{} //@ used("_", true) 73 74 type t10 struct{} //@ used("t10", true) 75 76 func (*t10) Foo() {} //@ used("Foo", true) 77 78 type t11 struct { //@ used("t11", true) 79 t10 //@ used("t10", true) 80 } 81 82 var _ = t11{} //@ used("_", true) 83 84 type i5 interface{} //@ used("i5", true) 85 type I6 interface { //@ used("I6", true) 86 i5 87 } 88 89 // When recursively looking for embedded exported fields, don't visit top-level type again 90 type t12 struct { //@ used("t12", true) 91 *t12 //@ used("t12", false) 92 F int //@ used("F", true) 93 } 94 95 var _ = t12{} //@ used("_", true) 96 97 // embedded fields whose names are exported are used, same as normal exported fields. 98 type T13 struct { //@ used("T13", true) 99 T14 //@ used("T14", true) 100 *T15 //@ used("T15", true) 101 } 102 103 type T14 struct{} //@ used("T14", true) 104 type T15 struct{} //@ used("T15", true)