github.com/amarpal/go-tools@v0.0.0-20240422043104-40142f59f616/unused/testdata/src/example.com/embedding-alias/embedding-alias.go (about)

     1  package pkg
     2  
     3  type s1 struct{} //@ used("s1", true)
     4  
     5  // Make sure the alias is used, and not just the type it points to.
     6  type a1 = s1 //@ used("a1", true)
     7  
     8  type E1 struct { //@ used("E1", true)
     9  	a1 //@ used("a1", true)
    10  }
    11  
    12  func F1(e E1) { //@ used("F1", true), used("e", true)
    13  	_ = e.a1
    14  }
    15  
    16  // Make sure fields get used correctly when embedded multiple times
    17  type s2 struct { //@ used("s2", true)
    18  	a int //@ used("a", true)
    19  	b int //@ used("b", true)
    20  	c int //@ used("c", false)
    21  }
    22  
    23  type a2 = s2 //@ used("a2", true)
    24  
    25  type E2 struct { //@ used("E2", true)
    26  	a2 //@ used("a2", true)
    27  }
    28  
    29  type E3 struct { //@ used("E3", true)
    30  	a2 //@ used("a2", true)
    31  }
    32  
    33  func F2(e E2) { //@ used("F2", true), used("e", true)
    34  	_ = e.a
    35  }
    36  
    37  func F3(e E3) { //@ used("F3", true), used("e", true)
    38  	_ = e.b
    39  }
    40  
    41  // Make sure embedding aliases to unnamed types works
    42  type a4 = struct { //@ used("a4", true)
    43  	a int //@ used("a", true)
    44  	b int //@ used("b", true)
    45  	c int //@ used("c", false)
    46  }
    47  
    48  type E4 struct { //@ used("E4", true)
    49  	a4 //@ used("a4", true)
    50  }
    51  
    52  type E5 struct { //@ used("E5", true)
    53  	a4 //@ used("a4", true)
    54  }
    55  
    56  func F4(e E4) { //@ used("F4", true), used("e", true)
    57  	_ = e.a
    58  }
    59  
    60  func F5(e E5) { //@ used("F5", true), used("e", true)
    61  	_ = e.b
    62  }