type HasName interface { Name() string }
func Greet(n HasName) { fmt.Printf("Hello %s!\n", n.Name()) }
type Joe struct {}
func (_ *Joe) Name() string { return "Joe" }
type Mike struct {}
func (_ *Mike) Name() string { return "Mike" }
func main() {
joe := &Joe{}
mike := &Mike{}
Greet(mike)
Greet(joe)
}
You have no idea how to read this?