Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator generates random usernames according to its configuration. It is immutable: builder methods return a new copy.
func NewGenerator ¶
func NewGenerator(opts GeneratorOptions) Generator
NewGenerator creates a Generator from the provided options. Zero values use defaults: language "en", CamelCase, 4 digit suffix.
func (Generator) WithLanguage ¶
WithLanguage returns a new Generator for the given language (ISO 639-1 code). Falls back to "en" if the language is unsupported.
func (Generator) WithSuffixLength ¶
WithSuffixLength returns a new Generator with the given suffix length. Pass 0 to disable the suffix entirely.
func (Generator) WithSuffixType ¶
func (g Generator) WithSuffixType(st SuffixType) Generator
WithSuffixType returns a new Generator with the given suffix type.
type GeneratorOptions ¶
type GeneratorOptions struct {
Language Language // default: EN
Case Case // default: CamelCase
SuffixLength int // number of suffix characters; default 4
SuffixType SuffixType // default: SuffixDigits
}
GeneratorOptions configures a Generator at creation time.
type Language ¶
type Language string
Language identifies a supported word-list language (ISO 639-1 code). Supported values: "en", "el", "es", "it", "pl", "pt".
type SuffixType ¶
type SuffixType string
SuffixType controls what characters are appended after the word pair.
const ( SuffixDigits SuffixType = "digits" // e.g. 4821 SuffixAlphanumeric SuffixType = "alphanumeric" // e.g. 4a2z )