I am new to Go and I'm wondering how I can implement a structure similar to abstract classes & methods in Java. In Java, I'd do the following:
abstract class A{
static method1(){
...
method2();
...
}
abstract method2();
}
class B extends A{
method2(){
...
}
}
class C extends A{
method2(){
...
}
}
I know about interfaces and structs. I could build an interface and then a struct to implement method1. But what about method2? I know that I can embed one interface in another and also a struct as a field of another struct. But I don't see a way to implement my structure with those methods.
The only solution I see is to implement method1 both in class B and class C. Isn't there another way?
Note: of course in my case it's not just one method. Also I've got a hierarchy of abstract classes and don't really want to move everything down to the 'subclasses'.
The examples I've found on the internet are mostly with only one method per interface. It would be great if one of you guys could give me a hint here! Thanks.