-
Notifications
You must be signed in to change notification settings - Fork 4
/
names.go
54 lines (45 loc) · 1.11 KB
/
names.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
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Cilium
package fake
import (
"fmt"
"math/rand"
)
// Adjective generates a random adjective.
func Adjective() string {
return adjectives[rand.Intn(len(adjectives))]
}
// AlphaNum generates a random alphanumeric string of the given length.
func AlphaNum(length int) string {
b := make([]byte, length)
for i := range b {
b[i] = alphanum[rand.Intn(len(alphanum))]
}
return string(b)
}
// App generates a random software application name.
func App() string {
return apps[rand.Intn(len(apps))]
}
// Noun generates a random noun.
func Noun() string {
return nouns[rand.Intn(len(nouns))]
}
// Name generates a random name.
func Name() string {
return fmt.Sprintf("%s_%s", Adjective(), Noun())
}
// Names generates a random set of names. It panics if n < 0.
func Names(n int) []string {
n = rand.Intn(n + 1)
names := make([]string, n)
for i := range n {
names[i] = Name()
}
return names
}
// DeploymentTier generates a random software deployment tier such as prod,
// staging, etc.
func DeploymentTier() string {
return tiers[rand.Intn(len(tiers))]
}