Go Type System(一)

2019-10-20  本文已影响0人  fly_in_sky

Overview of Go Type System

指针(Pointers)

Structs

Value Parts

// map types
type _map *hashtableImpl
// channel types
type _channel *channelImpl
// function types
type _function *functionImpl

type _slice struct {
    // referencing underlying elements
    elements unsafe.Pointer
    // number of elements and capacity
    len, cap int
}

type _string struct {
    elements *byte // referencing underlying bytes
    len      int   // number of bytes
}

type _interface struct {
    dynamicType  *_type         // the dynamic type
    dynamicValue unsafe.Pointer // the dynamic value
}

type _interface struct {
    dynamicTypeInfo *struct {
        dynamicType *_type       // the dynamic type
        methods     []*_function // method table
    }
    dynamicValue unsafe.Pointer // the dynamic value
}

Arrays, Slices and Maps in Go

Strings

上一篇 下一篇

猜你喜欢

热点阅读