forked from brianvoe/gofakeit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
movie.go
66 lines (52 loc) · 1.71 KB
/
movie.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
package gofakeit
import "math/rand"
func MovieName() string { return movieName(globalFaker.Rand) }
func (f *Faker) MovieName() string { return movieName(f.Rand) }
func movieName(r *rand.Rand) string { return getRandValue(r, []string{"movie", "name"}) }
func MovieGenre() string { return movieGenre(globalFaker.Rand) }
func (f *Faker) MovieGenre() string { return movieGenre(f.Rand) }
func movieGenre(r *rand.Rand) string { return getRandValue(r, []string{"movie", "genre"}) }
type MovieInfo struct {
Name string `json:"name" xml:"name"`
Genre string `json:"genre" xml:"genre"`
}
func Movie() *MovieInfo { return movie(globalFaker.Rand) }
func (f *Faker) Movie() *MovieInfo { return movie(f.Rand) }
func movie(r *rand.Rand) *MovieInfo {
return &MovieInfo{
Name: movieName(r),
Genre: movieGenre(r),
}
}
func addMovieLookup() {
AddFuncLookup("movie", Info{
Display: "Movie",
Category: "movie",
Description: "Random Movie data set",
Example: `{name: "The Matrix", genre: "Action"}`,
Output: "map[string]string",
Generate: func(r *rand.Rand, m *MapParams, info *Info) (interface{}, error) {
return movie(r), nil
},
})
AddFuncLookup("moviename", Info{
Display: "Movie Name",
Category: "movie",
Description: "Random movie name",
Example: "The Matrix",
Output: "string",
Generate: func(r *rand.Rand, m *MapParams, info *Info) (interface{}, error) {
return movieName(r), nil
},
})
AddFuncLookup("moviegenre", Info{
Display: "Genre",
Category: "movie",
Description: "Random movie genre",
Example: "Action",
Output: "string",
Generate: func(r *rand.Rand, m *MapParams, info *Info) (interface{}, error) {
return movieGenre(r), nil
},
})
}