10 2021 档案
摘要:// 多态 // 示例 package main import ( "fmt" ) type notifier interface { notify() } type user struct{ name string email string } func (u *user) notify(){ f
阅读全文
摘要://从接收者类型的角度来看方法集 Methods Receivers Values (t T) T and *T (t *T) *T 如果使用指针接收者来实现一个接口,那么只有指向那个类型的指针才能够实现对应的接口。 如果使用值接收者来实现一个接口,那么那个类型的值和指针都能够实现对应的接口 //
阅读全文