Files
comicverse/internals/randname/randname.go

34 lines
586 B
Go

package randname
import (
_ "embed"
"fmt"
"math/rand"
"strings"
)
// TODO: Make generator be based on fantasy, sci-fi and other literature
// and artistic names.
//go:embed adjectives.txt
var adjectives string
//go:embed names.txt
var names string
var (
adjectivesList = strings.Split(adjectives, "\n")
namesList = strings.Split(names, "\n")
)
func New(sep ...string) string {
if len(sep) == 0 {
sep = append(sep, " ")
}
a := adjectivesList[rand.Intn(len(adjectivesList))]
n := namesList[rand.Intn(len(namesList))]
return fmt.Sprintf("%s%s%s", a, sep[0], n)
}