-
Notifications
You must be signed in to change notification settings - Fork 5
/
convertion.go
119 lines (99 loc) · 1.93 KB
/
convertion.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package t
type iConvertion interface {
Interface() interface{}
// ToPredict 转换对象为 string 类型
String() string
Float64() float64
Float32() float32
Int64() int64
Int() int
Int32() int32
Int16() int16
Int8() int8
Uint64() uint64
Uint() uint
Uint32() uint32
Uint16() uint16
Uint8() uint8
Bool() bool
Byte() byte
Bytes() []byte
Rune() rune
Runes() []rune
}
// Interface ...
func (tc TypeContext) Interface() interface{} {
return tc.val
}
// ToPredict ...
func (tc TypeContext) String() string {
return ParseString(tc.val)
}
// Float64 ...
func (tc TypeContext) Float64() float64 {
return ParseFloat64(tc.val)
}
// Float32 ...
func (tc TypeContext) Float32() float32 {
return ParseFloat32(tc.val)
}
// Int64 ...
func (tc TypeContext) Int64() int64 {
return ParseInt64(tc.val)
}
// Int ...
func (tc TypeContext) Int() int {
return ParseInt(tc.val)
}
// Int32 ...
func (tc TypeContext) Int32() int32 {
return int32(ParseInt64(tc.val))
}
// Int16 ...
func (tc TypeContext) Int16() int16 {
return int16(ParseInt64(tc.val))
}
// Int8 ...
func (tc TypeContext) Int8() int8 {
return int8(ParseInt64(tc.val))
}
// Uint64 ...
func (tc TypeContext) Uint64() uint64 {
return ParseUint64(tc.val)
}
// Uint ...
func (tc TypeContext) Uint() uint {
return ParseUint(tc.val)
}
// Uint32 ...
func (tc TypeContext) Uint32() uint32 {
return uint32(ParseUint(tc.val))
}
// Uint16 ...
func (tc TypeContext) Uint16() uint16 {
return uint16(ParseUint(tc.val))
}
// Uint8 ...
func (tc TypeContext) Uint8() uint8 {
return uint8(ParseUint(tc.val))
}
// Bool ...
func (tc TypeContext) Bool() bool {
return ParseBool(tc.val)
}
// Byte ...
func (tc TypeContext) Byte() byte {
return ParseByte(tc.val)
}
// Bytes ...
func (tc TypeContext) Bytes() []byte {
return ParseBytes(tc.val)
}
// Rune ...
func (tc TypeContext) Rune() rune {
return ParseRune(tc.val)
}
// ParseRunes ...
func (tc TypeContext) Runes() []rune {
return ParseRunes(tc.val)
}