Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type base interface {
- func1()
- func2()
- common_func()
- }
- type derived1 struct {
- base // anonymous meaning inheritence
- data DatumType
- }
- type derived2 struct {
- base // anonymous meaning inheritence
- data DatumType
- }
- type base struct{
- data DatumType
- }
- func (b base) func1(){
- }
- func (b base) func2(){
- }
- func (b base) common_func(){
- }
- type derived1 struct {
- base // anonymous meaning embedding
- }
- type derived2 struct {
- base // anonymous meaning embedding
- }
- d := derived1{}
- d.func1()
- d.func2()
- d.common_func()
- d.base.data = something
- type common struct {
- data DatumType
- }
- func (c *common) commonFunc() {
- // Do something with data.
- }
- type derived1 struct {
- common
- otherField1 int
- }
- // Implement other methods on derived1.
- type derived2 struct {
- common
- otherField2 string
- }
- // Implement other methods on derived2.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement