Documentation
¶
Index ¶
- Constants
- func GetNameWithType(index int, formatter Formatter, t NameType) string
- func Name(formatter Formatter, index int) string
- func PseudoRandomName(seed int, eliminateCloseNames bool, formatter Formatter) (int, string)
- func RandomName(formatter Formatter) string
- type CapitalizedSpaceFormatter
- type EmptyFormatter
- type Formatter
- type LowercaseDashFormatter
- type NameType
- type UppercaseSpaceFormatter
Constants ¶
const (
// MASK is a 25-bit mask (2^25 - 1). Kept exported to avoid breaking callers.
MASK = (1 << 25) - 1
)
Variables ¶
This section is empty.
Functions ¶
func GetNameWithType ¶ added in v1.2.0
func PseudoRandomName ¶
PseudoRandomName returns a pseudorandom name for a given seed value and formats it via the provided formatter. It returns the next LFSR state (to be used for the next call) and the generated, formatted name.
The sequence is unique until it cycles after 2^25 - 2 states, excluding the all-zero state.
When eliminateCloseNames is true, successive calls never return the same firstname or surname. This skips 66,046 possible states and the loop becomes slightly shorter.
func RandomName ¶
RandomName returns a random formatted name using the provided Formatter. It selects a random index from the full set of available entries.
Types ¶
type CapitalizedSpaceFormatter ¶
type CapitalizedSpaceFormatter struct {
// contains filtered or unexported fields
}
CapitalizedSpaceFormatter joins first and last name in capitalized form with a space.
func NewCapitalizedSpaceFormatter ¶
func NewCapitalizedSpaceFormatter() *CapitalizedSpaceFormatter
NewCapitalizedSpaceFormatter creates a new CapitalizedSpaceFormatter. Uses English capitalization rules.
func (*CapitalizedSpaceFormatter) Format ¶
func (f *CapitalizedSpaceFormatter) Format(firstname, surname string) string
Format returns the names with each word capitalized.
type EmptyFormatter ¶
type EmptyFormatter struct{}
EmptyFormatter always returns an empty string.
func NewEmptyFormatter ¶
func NewEmptyFormatter() *EmptyFormatter
NewEmptyFormatter creates a new EmptyFormatter.
func (*EmptyFormatter) Format ¶
func (*EmptyFormatter) Format(_, _ string) string
Format ignores inputs and returns an empty string.
type LowercaseDashFormatter ¶
type LowercaseDashFormatter struct{}
LowercaseDashFormatter joins first and last name in lowercase with a dash.
func NewLowercaseDashFormatter ¶
func NewLowercaseDashFormatter() *LowercaseDashFormatter
NewLowercaseDashFormatter creates a new LowercaseDashFormatter.
func (*LowercaseDashFormatter) Format ¶
func (*LowercaseDashFormatter) Format(firstname, surname string) string
Format returns the names in lowercase separated by a dash.
type UppercaseSpaceFormatter ¶
type UppercaseSpaceFormatter struct{}
UppercaseSpaceFormatter joins first and last name in uppercase with a space.
func NewUppercaseSpaceFormatter ¶
func NewUppercaseSpaceFormatter() *UppercaseSpaceFormatter
NewUppercaseSpaceFormatter creates a new UppercaseSpaceFormatter.
func (*UppercaseSpaceFormatter) Format ¶
func (*UppercaseSpaceFormatter) Format(firstname, surname string) string
Format returns the names in uppercase separated by a space.