type Foo struct {
...
}
type Bar struct {
Foo
}
...You can't pass Bar (or pointer to Bar) to anything that requires Foo (or pointer to Foo), even it looks like they'd have identical memory layouts and therefore be compatible, though that is exactly what inheritance aims to achieve in other OO languages.I should have included a section on the limitations of embedding. This is what happens when I don't stew on the writing for a day or two before putting it out there! I will have to make a pass through the article and clear up the terminology. Thanks for the feedback!
There is no support for inheritance in Go, calling struct embedding inheritance is incorrect. Inheritance implies a type hierarchy, there is no type hierarchy in Go, types are flat. If you think you can mimick inheritance with struct embedding you're going to feel a whole lot of pain when you pass values around functions then expect boxing / unboxing types to work in like C# or Java.
It's a bit more like PHP's traits - https://secure.php.net/manual/en/language.oop5.traits.php
Ruby's mixins are a bit similar as well - http://culttt.com/2015/07/08/working-with-mixins-in-ruby/
Think of it as language-assisted copy paste.