forked from brianvoe/gofakeit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
beer.go
208 lines (175 loc) · 4.95 KB
/
beer.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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
package gofakeit
import (
"math/rand"
"strconv"
)
// BeerName will return a random beer name
func BeerName() string {
return beerName(globalFaker.Rand)
}
// BeerName will return a random beer name
func (f *Faker) BeerName() string {
return beerName(f.Rand)
}
func beerName(r *rand.Rand) string {
return getRandValue(r, []string{"beer", "name"})
}
// BeerStyle will return a random beer style
func BeerStyle() string {
return beerStyle(globalFaker.Rand)
}
// BeerStyle will return a random beer style
func (f *Faker) BeerStyle() string {
return beerStyle(f.Rand)
}
func beerStyle(r *rand.Rand) string {
return getRandValue(r, []string{"beer", "style"})
}
// BeerHop will return a random beer hop
func BeerHop() string {
return beerHop(globalFaker.Rand)
}
// BeerHop will return a random beer hop
func (f *Faker) BeerHop() string {
return beerHop(f.Rand)
}
func beerHop(r *rand.Rand) string {
return getRandValue(r, []string{"beer", "hop"})
}
// BeerYeast will return a random beer yeast
func BeerYeast() string {
return beerYeast(globalFaker.Rand)
}
// BeerYeast will return a random beer yeast
func (f *Faker) BeerYeast() string {
return beerYeast(f.Rand)
}
func beerYeast(r *rand.Rand) string {
return getRandValue(r, []string{"beer", "yeast"})
}
// BeerMalt will return a random beer malt
func BeerMalt() string {
return beerMalt(globalFaker.Rand)
}
// BeerMalt will return a random beer malt
func (f *Faker) BeerMalt() string {
return beerMalt(f.Rand)
}
func beerMalt(r *rand.Rand) string {
return getRandValue(r, []string{"beer", "malt"})
}
// BeerAlcohol will return a random beer alcohol level between 2.0 and 10.0
func BeerAlcohol() string {
return beerAlcohol(globalFaker.Rand)
}
// BeerAlcohol will return a random beer alcohol level between 2.0 and 10.0
func (f *Faker) BeerAlcohol() string {
return beerAlcohol(f.Rand)
}
func beerAlcohol(r *rand.Rand) string {
return strconv.FormatFloat(float64Range(r, 2.0, 10.0), 'f', 1, 64) + "%"
}
// BeerIbu will return a random beer ibu value between 10 and 100
func BeerIbu() string {
return beerIbu(globalFaker.Rand)
}
// BeerIbu will return a random beer ibu value between 10 and 100
func (f *Faker) BeerIbu() string {
return beerIbu(f.Rand)
}
func beerIbu(r *rand.Rand) string {
return strconv.Itoa(randIntRange(r, 10, 100)) + " IBU"
}
// BeerBlg will return a random beer blg between 5.0 and 20.0
func BeerBlg() string {
return beerBlg(globalFaker.Rand)
}
// BeerBlg will return a random beer blg between 5.0 and 20.0
func (f *Faker) BeerBlg() string {
return beerBlg(f.Rand)
}
func beerBlg(r *rand.Rand) string {
return strconv.FormatFloat(float64Range(r, 5.0, 20.0), 'f', 1, 64) + "°Blg"
}
func addBeerLookup() {
AddFuncLookup("beername", Info{
Display: "Beer Name",
Category: "beer",
Description: "Random beer name",
Example: "Duvel",
Output: "string",
Generate: func(r *rand.Rand, m *MapParams, info *Info) (interface{}, error) {
return beerName(r), nil
},
})
AddFuncLookup("beerstyle", Info{
Display: "Beer Style",
Category: "beer",
Description: "Random beer style",
Example: "European Amber Lager",
Output: "string",
Generate: func(r *rand.Rand, m *MapParams, info *Info) (interface{}, error) {
return beerStyle(r), nil
},
})
AddFuncLookup("beerhop", Info{
Display: "Beer Hop",
Category: "beer",
Description: "Random beer hop type",
Example: "Glacier",
Output: "string",
Generate: func(r *rand.Rand, m *MapParams, info *Info) (interface{}, error) {
return beerHop(r), nil
},
})
AddFuncLookup("beeryeast", Info{
Display: "Beer Yeast",
Category: "beer",
Description: "Random beer yeast value",
Example: "1388 - Belgian Strong Ale",
Output: "string",
Generate: func(r *rand.Rand, m *MapParams, info *Info) (interface{}, error) {
return beerYeast(r), nil
},
})
AddFuncLookup("beermalt", Info{
Display: "Beer Malt",
Category: "beer",
Description: "Random beer malt",
Example: "Munich",
Output: "string",
Generate: func(r *rand.Rand, m *MapParams, info *Info) (interface{}, error) {
return beerMalt(r), nil
},
})
AddFuncLookup("beeralcohol", Info{
Display: "Beer Alcohol",
Category: "beer",
Description: "Random alcohol percentage",
Example: "2.7%",
Output: "string",
Generate: func(r *rand.Rand, m *MapParams, info *Info) (interface{}, error) {
return beerAlcohol(r), nil
},
})
AddFuncLookup("beeribu", Info{
Display: "Beer IBU",
Category: "beer",
Description: "Random beer ibu",
Example: "29 IBU",
Output: "string",
Generate: func(r *rand.Rand, m *MapParams, info *Info) (interface{}, error) {
return beerIbu(r), nil
},
})
AddFuncLookup("beerblg", Info{
Display: "Beer BLG",
Category: "beer",
Description: "Random beer blg",
Example: "6.4°Blg",
Output: "string",
Generate: func(r *rand.Rand, m *MapParams, info *Info) (interface{}, error) {
return beerBlg(r), nil
},
})
}