Documentation
¶
Index ¶
- Variables
- type Generator
- func (g *Generator) Configure(conf *data.Config, words *data.WordCollection) (err error)
- func (g *Generator) Generate() (words []string, err error)
- func (g *Generator) GenerateFrom(dictionary string) (words []string, err error)
- func (g *Generator) GenerateN(count int) (words []string, err error)
- func (g *Generator) ReplaceDefaultDict(name string)
- func (g *Generator) ReplaceRandom(r func(max int) int)
- func (g *Generator) Slug() (slug string, err error)
- func (g *Generator) SlugFrom(dictionary string) (slug string, err error)
- func (g *Generator) SlugN(count int) (slug string, err error)
Constants ¶
This section is empty.
Variables ¶
var ( Generate = defaultGenerator.Generate GenerateN = defaultGenerator.GenerateN GenerateFrom = defaultGenerator.GenerateFrom Slug = defaultGenerator.Slug SlugN = defaultGenerator.SlugN SlugFrom = defaultGenerator.SlugFrom )
Functions ¶
This section is empty.
Types ¶
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
coolname generator
Zero value is perfectly usable (will load default configuration)
Tunable knobs:
- After instanciation user may provide custom configuration and word list via Configure() method
- User may also override the default dictionary name (ReplaceDefaultDict) and random number generator (ReplaceRandom)
func (*Generator) Configure ¶
Load configuration. Calling this method is not required if default word collection is OK for you
func (*Generator) Generate ¶
Return a slice of random words (most likely will result in length of 4)
func (*Generator) GenerateFrom ¶
Return a random word combination from dictionary specified by name
Valid dictionary names are top level keys from config.json
func (*Generator) GenerateN ¶
Return a slice of N random words
Prepositions and articles (of, from, the) are not counted as words, so the resulting slice may contain more elements than `count`
Currently only dictionaries for 2, 3 and 4 words are defined upstream (see config.json)
func (*Generator) ReplaceDefaultDict ¶
Set dictionary name to be used by Slug() and Generate()
Default: "all"
func (*Generator) ReplaceRandom ¶
Provide a custom random number generator
The function `r` must return integer values from a half-open interval [0, max) for any non-negative `max` value
Default: math/rand::IntN()