3 ms·
> I am sure you know that there is no inheritance in Go https://golangdocs.com/inheritance-in-golang https://golangdocs.com/inheritance-in-golang
by shakow 6y ago
> I am sure you know that there is no inheritance in Go
https://golangdocs.com/inheritance-in-golang https://golangdocs.com/inheritance-in-golang
- majewsky 6y agoThis tries really hard to look like an official resource, but it seems to be run by some random IT consultancy. What they call inheritance is a narrow syntactic sugar intended to forward method calls to a member without having to write something like func (x Outer) Frobnicate(val int) { x.inner.Frobnicate(val) } by hand. It's arguably not inheritance because Liskov substitution is not permitted: type Outer struct { Inner } func process(i Inner) { ... } var x Outer process(x) // ERROR: type mismatch process(x.Inner) // OK
- arp242 6y agoThis is a bad article; struct embedding is not inheritance, and mistaking it for such is a classic case of "Java/Python programmer tries to use Go and shoehorns concepts from those languages in Go" that the post mentions. This entire website seems pretty ... meh. It's like the W3Schools of Go.