-
Notifications
You must be signed in to change notification settings - Fork 44
/
register.go
70 lines (63 loc) · 1.95 KB
/
register.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
package generators
// the implementation of it should not have status
type Generator interface {
Gen() string
}
var gmap = make(map[string]Generator)
func Get(name string) Generator {
g, ok := gmap[name]
if !ok {
return nil
}
return g
}
func Traverse(h func(string, Generator)) {
for k, v := range gmap {
h(k, v)
}
}
func init() {
gmap["digit"] = &Digit{}
gmap["letter"] = &Letter{}
/* temporal
yyyy-MM-dd HH:mm:ss.SSS
*/
gmap["date"] = newTemporal(yyyy, dd)
gmap["year"] = newTemporal(yyyy, yyyy)
gmap["month"] = newTemporal(MM, MM)
gmap["day"] = newTemporal(dd, dd)
gmap["hour"] = newTemporal(HH, HH)
gmap["minute"] = newTemporal(mm, mm)
gmap["second"] = newTemporal(ss, ss)
gmap["microsecond"] = newTemporal(SSS, SSS)
gmap["time"] = newTemporal(HH, ss)
gmap["datetime"] = newTemporal(yyyy, ss)
gmap["second_microsecond"] = newTemporal(ss, SSS)
gmap["minute_microsecond"] = newTemporal(mm, SSS)
gmap["minute_second"] = newTemporal(mm, ss)
gmap["hour_microsecond"] = newTemporal(HH, SSS)
gmap["hour_second"] = newTemporal(HH, ss)
gmap["hour_minute"] = newTemporal(HH, mm)
gmap["day_microsecond"] = newTemporal(dd, SSS)
gmap["day_second"] = newTemporal(dd, ss)
gmap["day_minute"] = newTemporal(dd, mm)
gmap["day_hour"] = newTemporal(dd, HH)
gmap["year_month"] = newTemporal(yyyy, MM)
gmap["timestamp"] = &Timestamp{}
gmap["english"] = newEnglish()
gmap["char"] = NewChar(10)
gmap["bool"] = newInt(0, 1, "")
gmap["boolean"] = newInt(0, 1, "")
gmap["tinyint"] = newInt(-128, 127, "")
gmap["tinyint_unsigned"] = newInt(0, 255, "")
gmap["smallint"] = newInt(-32768, 32767, "")
gmap["smallint_unsigned"] = newInt(0, 65535, "")
gmap["mediumint"] = newInt(-8388608, 8388607, "")
gmap["mediumint_unsigned"] = newInt(0, 16777215, "")
gmap["bigint"] = newBigInt(false)
gmap["bigint_unsigned"] = newBigInt(true)
gmap["int"] = newInt(0, -1, "")
gmap["int_usigned"] = &Uint{}
gmap["integer"] = newInt(0, -1, "")
gmap["decimal"] = &Decimal{}
}