-
Notifications
You must be signed in to change notification settings - Fork 225
/
convert.go
70 lines (61 loc) · 1.31 KB
/
convert.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 linq
type intConverter func(interface{}) int64
func getIntConverter(data interface{}) intConverter {
switch data.(type) {
case (int):
return func(i interface{}) int64 {
return int64(i.(int))
}
case (int8):
return func(i interface{}) int64 {
return int64(i.(int8))
}
case (int16):
return func(i interface{}) int64 {
return int64(i.(int16))
}
case (int32):
return func(i interface{}) int64 {
return int64(i.(int32))
}
}
return func(i interface{}) int64 {
return i.(int64)
}
}
type uintConverter func(interface{}) uint64
func getUIntConverter(data interface{}) uintConverter {
switch data.(type) {
case (uint):
return func(i interface{}) uint64 {
return uint64(i.(uint))
}
case (uint8):
return func(i interface{}) uint64 {
return uint64(i.(uint8))
}
case (uint16):
return func(i interface{}) uint64 {
return uint64(i.(uint16))
}
case (uint32):
return func(i interface{}) uint64 {
return uint64(i.(uint32))
}
}
return func(i interface{}) uint64 {
return i.(uint64)
}
}
type floatConverter func(interface{}) float64
func getFloatConverter(data interface{}) floatConverter {
switch data.(type) {
case (float32):
return func(i interface{}) float64 {
return float64(i.(float32))
}
}
return func(i interface{}) float64 {
return i.(float64)
}
}