forked from brianvoe/gofakeit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
movie.go
68 lines (55 loc) · 1.8 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
67
68
package gofakeit
func MovieName() string { return movieName(GlobalFaker) }
func (f *Faker) MovieName() string { return movieName(f) }
func movieName(f *Faker) string { return getRandValue(f, []string{"movie", "name"}) }
func MovieGenre() string { return movieGenre(GlobalFaker) }
func (f *Faker) MovieGenre() string { return movieGenre(f) }
func movieGenre(f *Faker) string { return getRandValue(f, []string{"movie", "genre"}) }
type MovieInfo struct {
Name string `json:"name" xml:"name"`
Genre string `json:"genre" xml:"genre"`
}
func Movie() *MovieInfo { return movie(GlobalFaker) }
func (f *Faker) Movie() *MovieInfo { return movie(f) }
func movie(f *Faker) *MovieInfo {
return &MovieInfo{
Name: movieName(f),
Genre: movieGenre(f),
}
}
func addMovieLookup() {
AddFuncLookup("movie", Info{
Display: "Movie",
Category: "movie",
Description: "A story told through moving pictures and sound",
Example: `{
"name": "Psycho",
"genre": "Mystery"
}`,
Output: "map[string]string",
ContentType: "application/json",
Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
return movie(f), nil
},
})
AddFuncLookup("moviename", Info{
Display: "Movie Name",
Category: "movie",
Description: "Title or name of a specific film used for identification and reference",
Example: "The Matrix",
Output: "string",
Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
return movieName(f), nil
},
})
AddFuncLookup("moviegenre", Info{
Display: "Genre",
Category: "movie",
Description: "Category that classifies movies based on common themes, styles, and storytelling approaches",
Example: "Action",
Output: "string",
Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
return movieGenre(f), nil
},
})
}