type.go
type Array struct {
len int64
elem Type
}
func NewArray(elem Type, len int64) *Array { return &Array{len, elem} }
func (a *Array) Len() int64 { return a.len }
func (a *Array) Elem() Type { return a.elem }
type Map struct {
key, elem Type
}
func NewMap(key, elem Type) *Map {
return &Map{key, elem}
}
func (m *Map) Key() Type { return m.key }
func (m *Map) Elem() Type { return m.elem }
src/reflect/value.go
type stringHeader struct {
Data unsafe.Pointer
Len int
}
type sliceHeader struct {
Data unsafe.Pointer //uintptr
Len int
Cap int
}
type stringHeader struct {
Data unsafe.Pointer //uintptr
Len int
}
type emptyInterface struct {
typ *rtype
word unsafe.Pointer
}
// nonEmptyInterface is the header for an interface value with methods.
type nonEmptyInterface struct {
// see ../runtime/iface.go:/Itab
itab *struct {
ityp *rtype // static interface type
typ *rtype // dynamic concrete type
hash uint32 // copy of typ.hash
_ [4]byte
fun [100000]unsafe.Pointer // method table
}
word unsafe.Pointer
}
// A runtimeSelect is a single case passed to rselect.
// This must match ../runtime/select.go:/runtimeSelect
type runtimeSelect struct {
dir SelectDir // SelectSend, SelectRecv or SelectDefault
typ *rtype // channel type
ch unsafe.Pointer // channel
val unsafe.Pointer // ptr to data (SendDir) or ptr to receive buffer (RecvDir)
}
type SelectCase struct {
Dir SelectDir // direction of case
Chan Value // channel to use (for send or receive)
Send Value // value to send (for send)
}
有疑问加站长微信联系(非本文作者)