After struct embedding of S1 in S2, all methods of S1 will be available in S2. So, this is ok !!
Warm Regards, Asit Dhal http://bit.ly/193ASIT On 8/19/2016 5:13:09 PM, Ian Lance Taylor <i...@golang.org> wrote: On Thu, Aug 18, 2016 at 10:16 PM, T L wrote: > > package main > > type S1 struct { } > > func (*S1) f() {} > > type S2 struct { S1 } > > // var _ = S1.f // S1.f undefined (type S1 has no method f) > // var _ = S2.f // S2.f undefined (type S2 has no method f) > var _ = (*S2).f // ok! Not weird. See the rules about method sets when embedding types. https://golang.org/ref/spec#Method_sets https://golang.org/ref/spec#Struct_types Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.