News for hackers. Stuff that matters.
Re:Struct composition with Go by aikah on Friday May 22, 2015 @01:53PM (#9589880)
This is not inheritance, careful about what you say here since it is totally misleading. while embedding structs is useful in a lot of cases, it might yield unexpected results if you expect embedding to work "more like inheritance".

ex

    type A struct{}
  
    func (a *A)GetSelf()*A{return a}

    type B struct{ A }

    b:=&B{A{}}

b.GetSelf() returns type A , not type B

It gets even more confusing when you start embedding interfaces in structs.

There are no comments on this comment yet.