Go语言中的类型和接口及方法的关系
朦着用了这么久, 概念一直不是很清楚, 经过这一轮的学习, 应该在大脑里可以进入深层记忆了吧。 函数是单一化应用。 方法可以绑定于类型。 接口用于定义方法集(记住:是方法集,不是函数集) 至于多态~~~ 稍后就到! package main import ( "fmt" ) type notifier interface { notify() } type user struct { name string email string } func (u user) notify() { fmt.Printf("Sending User Email To %s<%s>\n", u.name, u.email) } func (u *user) changeEmail(email string) { u.email = email } func main() { bill := user{"Bill", "bill@email.com"} sendNotification(bill) } func sendNotification(n notifier) { n.notify(...