forked from brianvoe/gofakeit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
languages.go
91 lines (71 loc) · 3.16 KB
/
languages.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
package gofakeit
import "math/rand"
// Language will return a random language
func Language() string { return language(globalFaker.Rand) }
// Language will return a random language
func (f *Faker) Language() string { return language(f.Rand) }
func language(r *rand.Rand) string { return getRandValue(r, []string{"language", "long"}) }
// LanguageAbbreviation will return a random language abbreviation
func LanguageAbbreviation() string { return languageAbbreviation(globalFaker.Rand) }
// LanguageAbbreviation will return a random language abbreviation
func (f *Faker) LanguageAbbreviation() string { return languageAbbreviation(f.Rand) }
func languageAbbreviation(r *rand.Rand) string { return getRandValue(r, []string{"language", "short"}) }
// LanguageBCP will return a random language BCP (Best Current Practices)
func LanguageBCP() string { return languageBCP(globalFaker.Rand) }
// LanguageBCP will return a random language BCP (Best Current Practices)
func (f *Faker) LanguageBCP() string { return languageBCP(f.Rand) }
func languageBCP(r *rand.Rand) string { return getRandValue(r, []string{"language", "bcp"}) }
// ProgrammingLanguage will return a random programming language
func ProgrammingLanguage() string { return programmingLanguage(globalFaker.Rand) }
// ProgrammingLanguage will return a random programming language
func (f *Faker) ProgrammingLanguage() string { return programmingLanguage(f.Rand) }
func programmingLanguage(r *rand.Rand) string {
return getRandValue(r, []string{"language", "programming"})
}
// ProgrammingLanguageBest will return a random programming language
func ProgrammingLanguageBest() string { return programmingLanguageBest(globalFaker.Rand) }
// ProgrammingLanguageBest will return a random programming language
func (f *Faker) ProgrammingLanguageBest() string { return programmingLanguageBest(f.Rand) }
func programmingLanguageBest(r *rand.Rand) string { return "Go" }
func addLanguagesLookup() {
AddFuncLookup("language", Info{
Display: "Language",
Category: "language",
Description: "Random language",
Example: "Kazakh",
Output: "string",
Generate: func(r *rand.Rand, m *MapParams, info *Info) (interface{}, error) {
return language(r), nil
},
})
AddFuncLookup("languageabbreviation", Info{
Display: "Language Abbreviation",
Category: "language",
Description: "Random abbreviated language",
Example: "kk",
Output: "string",
Generate: func(r *rand.Rand, m *MapParams, info *Info) (interface{}, error) {
return languageAbbreviation(r), nil
},
})
AddFuncLookup("languagebcp", Info{
Display: "Language BCP",
Category: "language",
Description: "Random language BCP (Best Current Practices)",
Example: "en-US",
Output: "string",
Generate: func(r *rand.Rand, m *MapParams, info *Info) (interface{}, error) {
return languageBCP(r), nil
},
})
AddFuncLookup("programminglanguage", Info{
Display: "Programming Language",
Category: "language",
Description: "Random programming language",
Example: "Go",
Output: "string",
Generate: func(r *rand.Rand, m *MapParams, info *Info) (interface{}, error) {
return programmingLanguage(r), nil
},
})
}