Go is a programming language that uses composition over inheritance. Yet, it provides a feature known as Struct Embedding that abstracts this, and makes it seem as if Go supports inheritance, leading us to make wrong assumptions and fall into a trap I’ll demystify in this article. Particularly for those coming from an object-oriented language like Java.
In 2019 I was looking for a new, modern programming language to replace Java as my main language. I needed to rewrite an interpreter in a faster programming language as Java wasn’t quite working any more. My options were Rust, Go and Swift, from which I shortlisted Rust and Go.