摘要:
// 多态 // 示例 package main import ( "fmt" ) type notifier interface { notify() } type user struct{ name string email string } func (u *user) notify(){ f 阅读全文
posted @ 2021-10-29 15:21
我在路上回头看
阅读(75)
评论(0)
推荐(0)
摘要:
//从接收者类型的角度来看方法集 Methods Receivers Values (t T) T and *T (t *T) *T 如果使用指针接收者来实现一个接口,那么只有指向那个类型的指针才能够实现对应的接口。 如果使用值接收者来实现一个接口,那么那个类型的值和指针都能够实现对应的接口 // 阅读全文
posted @ 2021-10-29 15:11
我在路上回头看
阅读(62)
评论(0)
推荐(0)

浙公网安备 33010602011771号