-
Notifications
You must be signed in to change notification settings - Fork 7
/
int32.go
192 lines (162 loc) · 3.87 KB
/
int32.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
package ameda
import (
"math"
"strconv"
)
// Int32ToInterface converts int32 to interface.
func Int32ToInterface(v int32) interface{} {
return v
}
// Int32ToInterfacePtr converts int32 to *interface.
func Int32ToInterfacePtr(v int32) *interface{} {
r := Int32ToInterface(v)
return &r
}
// Int32ToString converts int32 to string.
func Int32ToString(v int32) string {
return strconv.FormatInt(int64(v), 10)
}
// Int32ToStringPtr converts int32 to *string.
func Int32ToStringPtr(v int32) *string {
r := Int32ToString(v)
return &r
}
// Int32ToBool converts int32 to bool.
func Int32ToBool(v int32) bool {
return v != 0
}
// Int32ToBoolPtr converts int32 to *bool.
func Int32ToBoolPtr(v int32) *bool {
r := Int32ToBool(v)
return &r
}
// Int32ToFloat32 converts int32 to float32.
func Int32ToFloat32(v int32) float32 {
return float32(v)
}
// Int32ToFloat32Ptr converts int32 to *float32.
func Int32ToFloat32Ptr(v int32) *float32 {
r := Int32ToFloat32(v)
return &r
}
// Int32ToFloat64 converts int32 to float64.
func Int32ToFloat64(v int32) float64 {
return float64(v)
}
// Int32ToFloat64Ptr converts int32 to *float64.
func Int32ToFloat64Ptr(v int32) *float64 {
r := Int32ToFloat64(v)
return &r
}
// Int32ToInt converts int32 to int.
func Int32ToInt(v int32) int {
return int(v)
}
// Int32ToIntPtr converts int32 to *int.
func Int32ToIntPtr(v int32) *int {
r := Int32ToInt(v)
return &r
}
// Int32ToInt8 converts int32 to int8.
func Int32ToInt8(v int32) (int8, error) {
if v > math.MaxInt8 || v < math.MinInt8 {
return 0, errOverflowValue
}
return int8(v), nil
}
// Int32ToInt8Ptr converts int32 to *int8.
func Int32ToInt8Ptr(v int32) (*int8, error) {
r, err := Int32ToInt8(v)
return &r, err
}
// Int32ToInt16 converts int32 to int16.
func Int32ToInt16(v int32) (int16, error) {
if v > math.MaxInt16 || v < math.MinInt16 {
return 0, errOverflowValue
}
return int16(v), nil
}
// Int32ToInt16Ptr converts int32 to *int16.
func Int32ToInt16Ptr(v int32) (*int16, error) {
r, err := Int32ToInt16(v)
return &r, err
}
// Int32ToInt32Ptr converts int32 to *int32.
func Int32ToInt32Ptr(v int32) *int32 {
return &v
}
// Int32ToInt64 converts int32 to int64.
func Int32ToInt64(v int32) int64 {
return int64(v)
}
// Int32ToInt64Ptr converts int32 to *int64.
func Int32ToInt64Ptr(v int32) *int64 {
r := Int32ToInt64(v)
return &r
}
// Int32ToUint converts int32 to uint.
func Int32ToUint(v int32) (uint, error) {
if v < 0 {
return 0, errNegativeValue
}
return uint(v), nil
}
// Int32ToUintPtr converts int32 to *uint.
func Int32ToUintPtr(v int32) (*uint, error) {
r, err := Int32ToUint(v)
return &r, err
}
// Int32ToUint8 converts int32 to uint8.
func Int32ToUint8(v int32) (uint8, error) {
if v < 0 {
return 0, errNegativeValue
}
if v > math.MaxUint8 {
return 0, errOverflowValue
}
return uint8(v), nil
}
// Int32ToUint8Ptr converts int32 to *uint8.
func Int32ToUint8Ptr(v int32) (*uint8, error) {
r, err := Int32ToUint8(v)
return &r, err
}
// Int32ToUint16 converts int32 to uint16.
func Int32ToUint16(v int32) (uint16, error) {
if v < 0 {
return 0, errNegativeValue
}
if v > math.MaxUint16 {
return 0, errOverflowValue
}
return uint16(v), nil
}
// Int32ToUint16Ptr converts int32 to *uint16.
func Int32ToUint16Ptr(v int32) (*uint16, error) {
r, err := Int32ToUint16(v)
return &r, err
}
// Int32ToUint32 converts int32 to uint32.
func Int32ToUint32(v int32) (uint32, error) {
if v < 0 {
return 0, errNegativeValue
}
return uint32(v), nil
}
// Int32ToUint32Ptr converts int32 to *uint32.
func Int32ToUint32Ptr(v int32) (*uint32, error) {
r, err := Int32ToUint32(v)
return &r, err
}
// Int32ToUint64 converts int32 to uint64.
func Int32ToUint64(v int32) (uint64, error) {
if v < 0 {
return 0, errNegativeValue
}
return uint64(v), nil
}
// Int32ToUint64Ptr converts int32 to *uint64.
func Int32ToUint64Ptr(v int32) (*uint64, error) {
r, err := Int32ToUint64(v)
return &r, err
}