A quick thought says Inheritance is not really a game in Go, however it embraces EmbeddedTypes for something similar.
Roughly -
typeBaseSensorstruct{}func(bs*BaseSensor)BeforeStart(){fmt.Println("Base Before Start")}func(bs*BaseSensor)AfterStart(){fmt.Println("Base After Start")}func(bs*BaseSensor)ShutdownStart(){fmt.Println("Base Shutdown")}func(bs*BaseSensor)Process(){fmt.Println("Base Process. You can panic here if you want it to be really abstract")}typeSensorAstruct{*BaseSensor}func(sa*SensorA)Process(){fmt.Println("Sensor A Process")}typeSensorBstruct{*BaseSensor}func(sb*SensorB)BeforeStart(){// If you want to call super like methodsb.BaseSensor.BeforeStart()fmt.Println("Sensor B BeforeStart")}func(sb*SensorB)Process(){fmt.Println("Sensor B Process")}
A quick thought says Inheritance is not really a game in Go, however it embraces EmbeddedTypes for something similar.
Roughly -
And then you can invoke them as follows -
Rahul already made the important part, I'd like to add code for Work()
then you can do something like following:
thanks