1 接口定义:
type iface_name interface{
//....
}
2 接口实现
// 非空接口
type iface struct {
tab *itab
data unsafe.Pointer // data *int
}
// 空接口
type iface struct {
_type *_type
data unsafe.Pointer // data *int
}
type _type struct {
size uintptr
hash uint32
_unused uint8
align uint8
fieldalign uint8
kind uint8
alg unsafe.Pointer
gc [2]uintptr
_string *string
x *uncommontype
ptrto *_type
zero *byte
}
参考: