-
Notifications
You must be signed in to change notification settings - Fork 1
/
types.go
103 lines (98 loc) · 1.34 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package types
import "fmt"
const (
T_null = iota
T_int // int64
T_bool
T_float // float64
T_array
T_string
T_timestamp
T_uint8
T_uint16
T_uint32
T_uint64
T_int8
T_int16
T_int32
T_int64
T_float32
T_float64
)
type T uint32
func (t T) Size() int {
switch t {
case T_null:
return 1
case T_int:
return 8
case T_bool:
return 1
case T_timestamp:
return 8
case T_float:
return 8
case T_string:
return 10
case T_uint8:
return 1
case T_uint16:
return 2
case T_uint32:
return 4
case T_uint64:
return 8
case T_int8:
return 1
case T_int16:
return 2
case T_int32:
return 4
case T_int64:
return 8
case T_float32:
return 4
case T_float64:
return 8
}
return -1
}
func (t T) String() string {
switch t {
case T_null:
return "NULL"
case T_int:
return "INT"
case T_bool:
return "BOOL"
case T_timestamp:
return "TIMESTAMP"
case T_float:
return "FLOAT"
case T_array:
return "ARRAY"
case T_string:
return "STRING"
case T_uint8:
return "UINT8"
case T_uint16:
return "UINT16"
case T_uint32:
return "UINT32"
case T_uint64:
return "UINT64"
case T_int8:
return "INT8"
case T_int16:
return "INT16"
case T_int32:
return "INT32"
case T_int64:
return "INT64"
case T_float32:
return "FLOAT32"
case T_float64:
return "FLOAT64"
}
panic(fmt.Errorf("unexpected oid: %d", t))
}