I am working on the rewriting of an old Java project to Go.
I've already done some Go at work but I can't figure out how I can translate my OOP (with abstract classes, etc.) to Go philosophy.
In the idea, I have two types (soon 3) that have some common methods, but some others (well just 1 or 2 max) should have the same signatures but not the same bodies.
I know Go does not have some kind of inheritance. For now I have something like this:
type A struct {...}
func (a *A) M1 (){ stuff1 }
func (a *A) M2 (){ stuff2 }
func (a *A) SM (){ special stuff A }
then:
type B struct {...}
func (b *B) M1 (){ stuff1 }
func (b *B) M2 (){ stuff2 }
func (b *B) SM (){ special stuff B }
I don't know how Go manages this. In Java I did an abstract class then implemented it with my two concrete classes.
What I would like is not having to duplicate M1() and M2(), but being able to have a generic type to call these methods on, then just have to define SM() for both types.