-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
tag_argument_extractor.go
189 lines (175 loc) · 4.92 KB
/
tag_argument_extractor.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
package faker
import (
"fmt"
"strconv"
"strings"
fakerErrors "github.com/go-faker/faker/v4/pkg/errors"
)
func extractFloat64FromTagArgs(args []string) (interface{}, error) {
bytes := 64
var floatValues []float64
for _, i := range args {
k := strings.TrimSpace(i)
j, err := strconv.ParseFloat(k, bytes)
if err != nil {
return nil, fmt.Errorf(fakerErrors.ErrUnsupportedTagArguments)
}
floatValues = append(floatValues, j)
}
toRet := floatValues[rand.Intn(len(floatValues))]
return toRet, nil
}
func extractFloat32FromTagArgs(args []string) (interface{}, error) {
bytes := 32
var floatValues []float32
for _, i := range args {
k := strings.TrimSpace(i)
j, err := strconv.ParseFloat(k, bytes)
if err != nil {
return nil, fmt.Errorf(fakerErrors.ErrUnsupportedTagArguments)
}
floatValues = append(floatValues, float32(j))
}
toRet := floatValues[rand.Intn(len(floatValues))]
return toRet, nil
}
func extractInt64FromTagArgs(args []string) (interface{}, error) {
bytes := 64
var floatValues []int64
for _, i := range args {
k := strings.TrimSpace(i)
j, err := strconv.ParseInt(k, 10, bytes)
if err != nil {
return nil, fmt.Errorf(fakerErrors.ErrUnsupportedTagArguments)
}
floatValues = append(floatValues, j)
}
toRet := floatValues[rand.Intn(len(floatValues))]
return toRet, nil
}
func extractInt32FromTagArgs(args []string) (interface{}, error) {
bytes := 32
var floatValues []int32
for _, i := range args {
k := strings.TrimSpace(i)
j, err := strconv.ParseInt(k, 10, bytes)
if err != nil {
return nil, fmt.Errorf(fakerErrors.ErrUnsupportedTagArguments)
}
floatValues = append(floatValues, int32(j))
}
toRet := floatValues[rand.Intn(len(floatValues))]
return toRet, nil
}
func extractInt16FromTagArgs(args []string) (interface{}, error) {
bytes := 16
var floatValues []int16
for _, i := range args {
k := strings.TrimSpace(i)
j, err := strconv.ParseInt(k, 10, bytes)
if err != nil {
return nil, fmt.Errorf(fakerErrors.ErrUnsupportedTagArguments)
}
floatValues = append(floatValues, int16(j))
}
toRet := floatValues[rand.Intn(len(floatValues))]
return toRet, nil
}
func extractInt8FromTagArgs(args []string) (interface{}, error) {
bytes := 8
var floatValues []int8
for _, i := range args {
k := strings.TrimSpace(i)
j, err := strconv.ParseInt(k, 10, bytes)
if err != nil {
return nil, fmt.Errorf(fakerErrors.ErrUnsupportedTagArguments)
}
floatValues = append(floatValues, int8(j))
}
toRet := floatValues[rand.Intn(len(floatValues))]
return toRet, nil
}
func extractIntFromTagArgs(args []string) (interface{}, error) {
bytes := 0
var floatValues []int
for _, i := range args {
k := strings.TrimSpace(i)
j, err := strconv.ParseInt(k, 10, bytes)
if err != nil {
return nil, fmt.Errorf(fakerErrors.ErrUnsupportedTagArguments)
}
floatValues = append(floatValues, int(j))
}
toRet := floatValues[rand.Intn(len(floatValues))]
return toRet, nil
}
func extractUint64FromTagArgs(args []string) (interface{}, error) {
bytes := 64
var floatValues []uint64
for _, i := range args {
k := strings.TrimSpace(i)
j, err := strconv.ParseUint(k, 10, bytes)
if err != nil {
return nil, fmt.Errorf(fakerErrors.ErrUnsupportedTagArguments)
}
floatValues = append(floatValues, j)
}
toRet := floatValues[rand.Intn(len(floatValues))]
return toRet, nil
}
func extractUint32FromTagArgs(args []string) (interface{}, error) {
bytes := 32
var floatValues []uint32
for _, i := range args {
k := strings.TrimSpace(i)
j, err := strconv.ParseUint(k, 10, bytes)
if err != nil {
return nil, fmt.Errorf(fakerErrors.ErrUnsupportedTagArguments)
}
floatValues = append(floatValues, uint32(j))
}
toRet := floatValues[rand.Intn(len(floatValues))]
return toRet, nil
}
func extractUint16FromTagArgs(args []string) (interface{}, error) {
bytes := 16
var floatValues []uint16
for _, i := range args {
k := strings.TrimSpace(i)
j, err := strconv.ParseUint(k, 10, bytes)
if err != nil {
return nil, fmt.Errorf(fakerErrors.ErrUnsupportedTagArguments)
}
floatValues = append(floatValues, uint16(j))
}
toRet := floatValues[rand.Intn(len(floatValues))]
return toRet, nil
}
func extractUint8FromTagArgs(args []string) (interface{}, error) {
bytes := 8
var floatValues []uint8
for _, i := range args {
k := strings.TrimSpace(i)
j, err := strconv.ParseUint(k, 10, bytes)
if err != nil {
return nil, fmt.Errorf(fakerErrors.ErrUnsupportedTagArguments)
}
floatValues = append(floatValues, uint8(j))
}
toRet := floatValues[rand.Intn(len(floatValues))]
return toRet, nil
}
func extractUintFromTagArgs(args []string) (interface{}, error) {
bytes := 0
var floatValues []uint
for _, i := range args {
k := strings.TrimSpace(i)
j, err := strconv.ParseUint(k, 10, bytes)
if err != nil {
return nil, fmt.Errorf(fakerErrors.ErrUnsupportedTagArguments)
}
floatValues = append(floatValues, uint(j))
}
toRet := floatValues[rand.Intn(len(floatValues))]
return toRet, nil
}