Source file
src/go/types/basic.go
1
2
3
4
5
6
7
8 package types
9
10
11 type BasicKind int
12
13 const (
14 Invalid BasicKind = iota
15
16
17 Bool
18 Int
19 Int8
20 Int16
21 Int32
22 Int64
23 Uint
24 Uint8
25 Uint16
26 Uint32
27 Uint64
28 Uintptr
29 Float32
30 Float64
31 Complex64
32 Complex128
33 String
34 UnsafePointer
35
36
37 UntypedBool
38 UntypedInt
39 UntypedRune
40 UntypedFloat
41 UntypedComplex
42 UntypedString
43 UntypedNil
44
45
46 Byte = Uint8
47 Rune = Int32
48 )
49
50
51 type BasicInfo int
52
53
54 const (
55 IsBoolean BasicInfo = 1 << iota
56 IsInteger
57 IsUnsigned
58 IsFloat
59 IsComplex
60 IsString
61 IsUntyped
62
63 IsOrdered = IsInteger | IsFloat | IsString
64 IsNumeric = IsInteger | IsFloat | IsComplex
65 IsConstType = IsBoolean | IsNumeric | IsString
66 )
67
68
69 type Basic struct {
70 kind BasicKind
71 info BasicInfo
72 name string
73 }
74
75
76 func (b *Basic) Kind() BasicKind { return b.kind }
77
78
79 func (b *Basic) Info() BasicInfo { return b.info }
80
81
82 func (b *Basic) Name() string { return b.name }
83
84 func (b *Basic) Underlying() Type { return b }
85 func (b *Basic) String() string { return TypeString(b, nil) }
86
View as plain text