Mastering-Go-Second-Edition/ch07/goCoIn.go
2019-01-10 22:09:57 +02:00

33 lines
398 B
Go

package main
import (
"fmt"
)
type first struct{}
func (a first) F() {
a.shared()
}
func (a first) shared() {
fmt.Println("This is shared() from first!")
}
type second struct {
first
}
func (a second) shared() {
fmt.Println("This is shared() from second!")
}
func main() {
first{}.F()
second{}.shared()
i := second{}
j := i.first
j.F()
// (i.first).F()
// (second{}.first).F()
}