23 ms·
If you like these notes you might also like my article on the subject: http://hackthology.com/object-oriented-inheritance-in-go.html http://hackthology.com/obje
by timtadh 10y ago
If you like these notes you might also like my article on the subject: http://hackthology.com/object-oriented-inheritance-in-go.html http://hackthology.com/object-oriented-inheritance-in-go.htm...
In general, using struct embedding to simulate sharing code and data is pretty limited. I rarely use this feature in my own code. However, having structs which automatically implement interfaces is awesome because you can "say what you need." You can also compose the interfaces together by embedding them. For example of that, checkout the Map type in my data-structures repository: https://godoc.org/github.com/timtadh/data-structures/types#Map https://godoc.org/github.com/timtadh/data-structures/types#M...