My goal is a different one. I'm trying to figure out how to best use the 
features of Go for code reuse and dynamic method dispatch _without_ 

Inheritance is a pretty strange language construct. It combines several 
different features in one. In my experience it's rare that all of these are 
needed at the same time and in this particular combination. I very much 
prefer to use the more basic and orthogonal features in Go: composition, 
embedding and interfaces.

On Tuesday, February 13, 2018 at 10:23:39 AM UTC+1, Haddock wrote:
> Hi Stefan,
> your solution falls short on addressing the underlying problem of how to 
> implement inheritance using dynamic dispatch through using interface. In 
> the article "Inner Pattern to mimic Method Overwriting in Go 
> <>" 
> there is a section with the headline "Motivation" where it says:
> This means that "f.MoreMagic()" in the last line in the code snippet below 
> (sample shamelessly stolen from [2 
> <>])
> does not print "foo magic" to the console as expected but "base magic".
> You can have a look at that article as it shows a solution how to get 
> accomplished what you were trying to do.
> Am Donnerstag, 8. Februar 2018 17:47:04 UTC+1 schrieb Stefan Nilsson:
>> Here is a short article about how to do OOP in Go with composition, 
>> structurally typed interfaces and, in some special cases, embedding. I 
>> believe this can often be a better approach than traditional OOP modeling 
>> using inheritance. I'd love to hear you thoughts.
>> Inheritance and OOP: Go one better 
>> <>

You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
For more options, visit

Reply via email to