Hacker News new | ask | show | jobs
by campoy 4289 days ago
"What we really want is a flattened struct"

That's what we call struct embedding. Check this http://talks.golang.org/2014/go4java.slide#33 for more details.

1 comments

Embedding won't give you a flattened structure with transparency you expect. In other words struct B embedded in struct A will only create a syntactic sugar so that you can access properties of B through A. It won't work in other cases .Check this out - http://stackoverflow.com/questions/24333494/golang-reflectio...

This is not to say inheritance is better. I am just illustrating how reuse is harder with go because it expects a lot more code to do a simple thing.