1 // Copyright 2017, The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE.md file.
7 type InterfaceA interface {
12 StructA struct{ X string } // Equal method on value receiver
13 StructB struct{ X string } // Equal method on pointer receiver
14 StructC struct{ X string } // Equal method (with interface argument) on value receiver
15 StructD struct{ X string } // Equal method (with interface argument) on pointer receiver
16 StructE struct{ X string } // Equal method (with interface argument on value receiver) on pointer receiver
17 StructF struct{ X string } // Equal method (with interface argument on pointer receiver) on value receiver
19 // These embed the above types as a value.
45 // These embed the above types as a pointer.
71 StructNo struct{ X string } // Equal method (with interface argument) on non-satisfying receiver
74 AssignB struct{ A int }
79 func (x StructA) Equal(y StructA) bool { return true }
80 func (x *StructB) Equal(y *StructB) bool { return true }
81 func (x StructC) Equal(y InterfaceA) bool { return true }
82 func (x StructC) InterfaceA() {}
83 func (x *StructD) Equal(y InterfaceA) bool { return true }
84 func (x *StructD) InterfaceA() {}
85 func (x *StructE) Equal(y InterfaceA) bool { return true }
86 func (x StructE) InterfaceA() {}
87 func (x StructF) Equal(y InterfaceA) bool { return true }
88 func (x *StructF) InterfaceA() {}
89 func (x StructNo) Equal(y InterfaceA) bool { return true }
91 func (x AssignA) Equal(y func() int) bool { return true }
92 func (x AssignB) Equal(y struct{ A int }) bool { return true }
93 func (x AssignC) Equal(y chan bool) bool { return true }
94 func (x AssignD) Equal(y <-chan bool) bool { return true }
97 a StructA, b StructB, c StructC, d StructD, e StructE, f StructF,
98 ap *StructA, bp *StructB, cp *StructC, dp *StructD, ep *StructE, fp *StructF,
99 a1 StructA1, b1 StructB1, c1 StructC1, d1 StructD1, e1 StructE1, f1 StructF1,
100 a2 StructA2, b2 StructB2, c2 StructC2, d2 StructD2, e2 StructE2, f2 StructF1,
117 b1.Equal(&b1.StructB)
123 a2.Equal(*a2.StructA)
132 privateStruct struct{ Public, private int }
133 PublicStruct struct{ Public, private int }
134 ParentStructA struct{ privateStruct }
135 ParentStructB struct{ PublicStruct }
136 ParentStructC struct {
140 ParentStructD struct {
144 ParentStructE struct {
148 ParentStructF struct {
153 ParentStructG struct {
156 ParentStructH struct {
159 ParentStructI struct {
163 ParentStructJ struct {
167 private privateStruct
171 func NewParentStructG() *ParentStructG {
172 return &ParentStructG{new(privateStruct)}
174 func NewParentStructH() *ParentStructH {
175 return &ParentStructH{new(PublicStruct)}
177 func NewParentStructI() *ParentStructI {
178 return &ParentStructI{new(privateStruct), new(PublicStruct)}
180 func NewParentStructJ() *ParentStructJ {
181 return &ParentStructJ{
182 privateStruct: new(privateStruct), PublicStruct: new(PublicStruct),
185 func (s *privateStruct) SetPrivate(i int) { s.private = i }
186 func (s *PublicStruct) SetPrivate(i int) { s.private = i }
187 func (s *ParentStructC) SetPrivate(i int) { s.private = i }
188 func (s *ParentStructD) SetPrivate(i int) { s.private = i }
189 func (s *ParentStructF) SetPrivate(i int) { s.private = i }
190 func (s *ParentStructA) PrivateStruct() *privateStruct { return &s.privateStruct }
191 func (s *ParentStructC) PrivateStruct() *privateStruct { return &s.privateStruct }
192 func (s *ParentStructE) PrivateStruct() *privateStruct { return &s.privateStruct }
193 func (s *ParentStructF) PrivateStruct() *privateStruct { return &s.privateStruct }
194 func (s *ParentStructG) PrivateStruct() *privateStruct { return s.privateStruct }
195 func (s *ParentStructI) PrivateStruct() *privateStruct { return s.privateStruct }
196 func (s *ParentStructJ) PrivateStruct() *privateStruct { return s.privateStruct }
197 func (s *ParentStructJ) Private() *privateStruct { return &s.private }