aboutsummaryrefslogtreecommitdiff
path: root/misc/namegen/namegen.go
blob: e43c7da888e7329ca8b6c860aeae68327752852b (plain)
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
// Package namegen generates a random name with one of several strategies.
package namegen

import (
	"math/rand"

	"cirello.io/goherokuname"
	"within.website/x/misc/namegen/elfs"
	"within.website/x/misc/namegen/tarot"
)

// Generator is a name generation function.
type Generator func() string

// AddGenerator adds a generator to the list
func AddGenerator(g Generator) {
	strats = append(strats, g)
}

func init() {
	AddGenerator(elfs.Next)
	AddGenerator(tarot.Next)
	AddGenerator(goherokuname.HaikunateHex)
}

var strats []Generator

// Next gives you the next name in the series.
func Next() string {
	gen := rand.Intn(len(strats))

	return strats[gen]()
}