forked from brianvoe/gofakeit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
food.go
178 lines (145 loc) · 4.87 KB
/
food.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
package gofakeit
import (
"math/rand"
"strings"
)
// Fruit will return a random fruit name
func Fruit() string { return fruit(globalFaker.Rand) }
// Fruit will return a random fruit name
func (f *Faker) Fruit() string { return fruit(f.Rand) }
func fruit(r *rand.Rand) string { return getRandValue(r, []string{"food", "fruit"}) }
// Vegetable will return a random vegetable name
func Vegetable() string { return vegetable(globalFaker.Rand) }
// Vegetable will return a random vegetable name
func (f *Faker) Vegetable() string { return vegetable(f.Rand) }
func vegetable(r *rand.Rand) string { return getRandValue(r, []string{"food", "vegetable"}) }
// Breakfast will return a random breakfast name
func Breakfast() string { return breakfast(globalFaker.Rand) }
// Breakfast will return a random breakfast name
func (f *Faker) Breakfast() string { return breakfast(f.Rand) }
func breakfast(r *rand.Rand) string {
v := getRandValue(r, []string{"food", "breakfast"})
return strings.ToUpper(v[:1]) + v[1:]
}
// Lunch will return a random lunch name
func Lunch() string { return lunch(globalFaker.Rand) }
// Lunch will return a random lunch name
func (f *Faker) Lunch() string { return lunch(f.Rand) }
func lunch(r *rand.Rand) string {
v := getRandValue(r, []string{"food", "lunch"})
return strings.ToUpper(v[:1]) + v[1:]
}
// Dinner will return a random dinner name
func Dinner() string { return dinner(globalFaker.Rand) }
// Dinner will return a random dinner name
func (f *Faker) Dinner() string { return dinner(f.Rand) }
func dinner(r *rand.Rand) string {
v := getRandValue(r, []string{"food", "dinner"})
return strings.ToUpper(v[:1]) + v[1:]
}
// Drink will return a random drink name
func Drink() string { return drink(globalFaker.Rand) }
// Drink will return a random drink name
func (f *Faker) Drink() string { return drink(f.Rand) }
func drink(r *rand.Rand) string {
v := getRandValue(r, []string{"food", "drink"})
return strings.ToUpper(v[:1]) + v[1:]
}
// Snack will return a random snack name
func Snack() string { return snack(globalFaker.Rand) }
// Snack will return a random snack name
func (f *Faker) Snack() string { return snack(f.Rand) }
func snack(r *rand.Rand) string {
v := getRandValue(r, []string{"food", "snack"})
return strings.ToUpper(v[:1]) + v[1:]
}
// Dessert will return a random dessert name
func Dessert() string { return dessert(globalFaker.Rand) }
// Dessert will return a random dessert name
func (f *Faker) Dessert() string { return dessert(f.Rand) }
func dessert(r *rand.Rand) string {
v := getRandValue(r, []string{"food", "dessert"})
return strings.ToUpper(v[:1]) + v[1:]
}
func addFoodLookup() {
AddFuncLookup("fruit", Info{
Display: "Fruit",
Category: "food",
Description: "Random fruit",
Example: "Peach",
Output: "string",
Generate: func(r *rand.Rand, m *MapParams, info *Info) (interface{}, error) {
return fruit(r), nil
},
})
AddFuncLookup("vegetable", Info{
Display: "Vegetable",
Category: "food",
Description: "Random vegetable",
Example: "Amaranth Leaves",
Output: "string",
Generate: func(r *rand.Rand, m *MapParams, info *Info) (interface{}, error) {
return vegetable(r), nil
},
})
AddFuncLookup("breakfast", Info{
Display: "Breakfast",
Category: "food",
Description: "Random breakfast",
Example: "Blueberry banana happy face pancakes",
Output: "string",
Generate: func(r *rand.Rand, m *MapParams, info *Info) (interface{}, error) {
return breakfast(r), nil
},
})
AddFuncLookup("lunch", Info{
Display: "Lunch",
Category: "food",
Description: "Random lunch",
Example: "No bake hersheys bar pie",
Output: "string",
Generate: func(r *rand.Rand, m *MapParams, info *Info) (interface{}, error) {
return lunch(r), nil
},
})
AddFuncLookup("dinner", Info{
Display: "Dinner",
Category: "food",
Description: "Random dinner",
Example: "Wild addicting dip",
Output: "string",
Generate: func(r *rand.Rand, m *MapParams, info *Info) (interface{}, error) {
return dinner(r), nil
},
})
AddFuncLookup("drink", Info{
Display: "Drink",
Category: "food",
Description: "Random drink",
Example: "Soda",
Output: "string",
Generate: func(r *rand.Rand, m *MapParams, info *Info) (interface{}, error) {
return drink(r), nil
},
})
AddFuncLookup("snack", Info{
Display: "Snack",
Category: "food",
Description: "Random snack",
Example: "Hoisin marinated wing pieces",
Output: "string",
Generate: func(r *rand.Rand, m *MapParams, info *Info) (interface{}, error) {
return snack(r), nil
},
})
AddFuncLookup("dessert", Info{
Display: "Dessert",
Category: "food",
Description: "Random dessert",
Example: "French napoleons",
Output: "string",
Generate: func(r *rand.Rand, m *MapParams, info *Info) (interface{}, error) {
return dessert(r), nil
},
})
}