forked from ebhomengo/niki
1
0
Fork 0
niki/vendor/github.com/brianvoe/gofakeit/v6/app.go

158 lines
2.2 KiB
Go
Raw Normal View History

2024-04-26 19:30:35 +00:00
package gofakeit
import (
"fmt"
"math/rand"
)
// AppName will generate a random app name
2024-04-26 19:30:35 +00:00
func AppName() string {
2024-04-26 19:30:35 +00:00
return appName(globalFaker.Rand)
2024-04-26 19:30:35 +00:00
}
// AppName will generate a random app name
2024-04-26 19:30:35 +00:00
func (f *Faker) AppName() string {
2024-04-26 19:30:35 +00:00
return appName(f.Rand)
2024-04-26 19:30:35 +00:00
}
func appName(r *rand.Rand) string {
2024-04-26 19:30:35 +00:00
name := ""
2024-04-26 19:30:35 +00:00
switch number(r, 1, 3) {
2024-04-26 19:30:35 +00:00
case 1:
2024-04-26 19:30:35 +00:00
name = noun(r) + verb(r)
2024-04-26 19:30:35 +00:00
case 2:
2024-04-26 19:30:35 +00:00
name = color(r) + noun(r)
2024-04-26 19:30:35 +00:00
case 3:
2024-04-26 19:30:35 +00:00
name = animal(r) + verb(r)
2024-04-26 19:30:35 +00:00
}
return title(name)
2024-04-26 19:30:35 +00:00
}
// AppVersion will generate a random app version
2024-04-26 19:30:35 +00:00
func AppVersion() string {
2024-04-26 19:30:35 +00:00
return appVersion(globalFaker.Rand)
2024-04-26 19:30:35 +00:00
}
// AppVersion will generate a random app version
2024-04-26 19:30:35 +00:00
func (f *Faker) AppVersion() string {
2024-04-26 19:30:35 +00:00
return appVersion(f.Rand)
2024-04-26 19:30:35 +00:00
}
func appVersion(r *rand.Rand) string {
2024-04-26 19:30:35 +00:00
return fmt.Sprintf("%d.%d.%d", number(r, 1, 5), number(r, 1, 20), number(r, 1, 20))
2024-04-26 19:30:35 +00:00
}
// AppAuthor will generate a random company or person name
2024-04-26 19:30:35 +00:00
func AppAuthor() string {
2024-04-26 19:30:35 +00:00
return appAuthor(globalFaker.Rand)
2024-04-26 19:30:35 +00:00
}
// AppAuthor will generate a random company or person name
2024-04-26 19:30:35 +00:00
func (f *Faker) AppAuthor() string {
2024-04-26 19:30:35 +00:00
return appAuthor(f.Rand)
2024-04-26 19:30:35 +00:00
}
func appAuthor(r *rand.Rand) string {
2024-04-26 19:30:35 +00:00
if boolFunc(r) {
2024-04-26 19:30:35 +00:00
return name(r)
2024-04-26 19:30:35 +00:00
}
return company(r)
2024-04-26 19:30:35 +00:00
}
func addAppLookup() {
2024-04-26 19:30:35 +00:00
AddFuncLookup("appname", Info{
Display: "App Name",
Category: "app",
2024-04-26 19:30:35 +00:00
Description: "Software program designed for a specific purpose or task on a computer or mobile device",
Example: "Parkrespond",
Output: "string",
2024-04-26 19:30:35 +00:00
Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
2024-04-26 19:30:35 +00:00
return appName(r), nil
2024-04-26 19:30:35 +00:00
},
})
AddFuncLookup("appversion", Info{
Display: "App Version",
Category: "app",
2024-04-26 19:30:35 +00:00
Description: "Particular release of an application in Semantic Versioning format",
Example: "1.12.14",
Output: "string",
2024-04-26 19:30:35 +00:00
Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
2024-04-26 19:30:35 +00:00
return appVersion(r), nil
2024-04-26 19:30:35 +00:00
},
})
AddFuncLookup("appauthor", Info{
Display: "App Author",
Category: "app",
2024-04-26 19:30:35 +00:00
Description: "Person or group creating and developing an application",
Example: "Qado Energy, Inc.",
Output: "string",
2024-04-26 19:30:35 +00:00
Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
2024-04-26 19:30:35 +00:00
return appAuthor(r), nil
2024-04-26 19:30:35 +00:00
},
})
2024-04-26 19:30:35 +00:00
}