感觉比java玄幻啊~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)} type admin ...
接口用于定义方法集(记住:是方法集,不是函数集)至于多态~稍后就到!package main import("fmt")type notifier interface { notify()} type user struct { name string email string } func(u user)notify(){ fmt.Printf("Sending User ...