Documentation
¶
Overview ¶
Package fname contains functions for generating random, human-friendly names.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Casing ¶ added in v0.2.0
type Casing int
func CasingFromString
deprecated
added in
v0.4.0
func ParseCasing ¶ added in v0.2.0
ParseCasing parses a casing string and returns the corresponding Casing value.
type Dictionary ¶
type Dictionary struct {
// contains filtered or unexported fields
}
Dictionary is a collection of words.
func NewCustomDictionary ¶ added in v0.5.0
func NewCustomDictionary(adjectives, adverbs, nouns, verbs []string) *Dictionary
NewCustomDictionary creates a Dictionary with caller-supplied word lists. Any nil slice falls back to the corresponding default embedded word list.
func NewDictionary ¶
func NewDictionary() *Dictionary
NewDictionary creates a new Dictionary backed by the default embedded word lists. To use custom word lists, use NewCustomDictionary and pass it via WithDictionary.
func (*Dictionary) LengthAdjective ¶
func (d *Dictionary) LengthAdjective() int
LengthAdjective returns the number of adjectives in the dictionary.
func (*Dictionary) LengthAdverb ¶
func (d *Dictionary) LengthAdverb() int
LengthAdverb returns the number of adverbs in the dictionary.
func (*Dictionary) LengthNoun ¶
func (d *Dictionary) LengthNoun() int
LengthNoun returns the number of nouns in the dictionary.
func (*Dictionary) LengthVerb ¶
func (d *Dictionary) LengthVerb() int
LengthVerb returns the number of verbs in the dictionary.
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator generates random name phrases. It is not safe for concurrent use from multiple goroutines; create a separate Generator per goroutine instead.
func NewGenerator ¶
func NewGenerator(opts ...GeneratorOption) *Generator
NewGenerator creates a new Generator.
type GeneratorOption ¶
type GeneratorOption func(*Generator)
GeneratorOption is a function that configures a Generator.
func WithCasing ¶ added in v0.2.0
func WithCasing(casing Casing) GeneratorOption
WithCasing sets the casing used to format the generated name.
func WithDelimiter ¶
func WithDelimiter(delimiter string) GeneratorOption
WithDelimiter sets the delimiter used to join words.
func WithDictionary ¶ added in v0.5.0
func WithDictionary(d *Dictionary) GeneratorOption
WithDictionary sets a custom Dictionary on the Generator. If d is nil, the default embedded Dictionary is used.
func WithSeed ¶
func WithSeed(seed int64) GeneratorOption
WithSeed sets the seed used to generate random numbers.
func WithSize ¶
func WithSize(size uint) (GeneratorOption, error)
WithSize sets the number of words in the generated name. Returns an error if size is outside the valid range [2, 4].
