Quick actions

cmd+k|ctrl+k

Navigation

Languages

Inheritance in Go

Snippet info

Language

Go

Visibility

public

Author

cheshirysh

Created

2017-03-07T22:29:48Z

Updated

2017-03-07T22:29:48Z

package main

import (
    "fmt"
)

type Base struct {}

func (entity Base) DoCommonLogic() {
    // ...
    entity.SpecificLogic()
    // ...
}

func (entity Base) SpecificLogic() {
    fmt.Println("A vot huy")
}

type Child struct {
    Base
}

func (entity Child) SpecificLogic() {
    fmt.Println("Inherited method")
}

func main() {
    (Child{Base{}}).DoCommonLogic()
}
INFO