Composition via embedding in Go
Unlock simpler design via a lesser known feature
I was introduced to type embedding (or embedding, in short) by Filippo Valsorda in one of his talks.
Apparently this is a lesser known (and lesser used) feature of the Go language, although it’s been around since the beginning. I hope I can spread with this post how it works and how it can be pragmatically helpful to create more expressive and reusable code.
What is embedding? Embedding is a powerful feature of the Go language that allows to compose types together, “bundling” new types that inherit the properties or behavior of the embedded types.
[Read More]