blob: 62f299e40453622ade6e53e91beba8b5694ffc3d [file] [log] [blame]
Zack Williamse940c7a2019-08-21 14:25:39 -07001package reflect2
2
3import (
4 "reflect"
5 "unsafe"
6)
7
8// DefaultTypeOfKind return the non aliased default type for the kind
9func DefaultTypeOfKind(kind reflect.Kind) Type {
10 return kindTypes[kind]
11}
12
13var 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}