github.com/modern-go/refLect2@v1.0.1/reflect2_kind.go (about)

     1  package reflect2
     2  
     3  import (
     4  	"reflect"
     5  	"unsafe"
     6  )
     7  
     8  // DefaultTypeOfKind return the non aliased default type for the kind
     9  func DefaultTypeOfKind(kind reflect.Kind) Type {
    10  	return kindTypes[kind]
    11  }
    12  
    13  var kindTypes = map[reflect.Kind]Type{
    14  	reflect.Bool:          TypeOf(true),
    15  	reflect.Uint8:         TypeOf(uint8(0)),
    16  	reflect.Int8:          TypeOf(int8(0)),
    17  	reflect.Uint16:        TypeOf(uint16(0)),
    18  	reflect.Int16:         TypeOf(int16(0)),
    19  	reflect.Uint32:        TypeOf(uint32(0)),
    20  	reflect.Int32:         TypeOf(int32(0)),
    21  	reflect.Uint64:        TypeOf(uint64(0)),
    22  	reflect.Int64:         TypeOf(int64(0)),
    23  	reflect.Uint:          TypeOf(uint(0)),
    24  	reflect.Int:           TypeOf(int(0)),
    25  	reflect.Float32:       TypeOf(float32(0)),
    26  	reflect.Float64:       TypeOf(float64(0)),
    27  	reflect.Uintptr:       TypeOf(uintptr(0)),
    28  	reflect.String:        TypeOf(""),
    29  	reflect.UnsafePointer: TypeOf(unsafe.Pointer(nil)),
    30  }