Documentation ¶
Overview ¶
Package namegenerator provides a simple way to generate random names.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // FamilyNames is a list of family names FamilyNames = []string{}/* 13479 elements not displayed */ // FemaleNames is a list of female names FemaleNames = []string{}/* 4999 elements not displayed */ // MaleNames is a list of male names MaleNames = []string{}/* 2943 elements not displayed */ // GeneralNames is a list of general names GeneralNames = []string{}/* 58254 elements not displayed */ )
Functions ¶
This section is empty.
Types ¶
type NameGenerator ¶
type NameGenerator interface { // Generate generates a name based on the gender. // // Example: // generator := namegenerator.NewGenerator() // name := generator.Generate() // fmt.Println(name) // Output: // `John-Smith` // Example with options: // generator := namegenerator.NewGenerator() // name := generator.Generate(namegenerator.WithGender(namegenerator.Male)) // fmt.Println(name) // Output: // `John-Smith` Generate(options ...Options) string // GenerateMultiple generates a list of names. // // Example: // generator := namegenerator.NewGenerator() // names := generator.GenerateMultiple(10) // fmt.Println(names) // Example with options: // generator := namegenerator.NewGenerator() // names := generator.GenerateMultiple(10, namegenerator.WithGender(namegenerator.Male)) // fmt.Println(names) GenerateMultiple(count int, options ...Options) []string // WithGender generates a name based on the gender. // // Example: // generator := namegenerator.NewGenerator().WithGender(namegenerator.Male) // name := generator.Generate() // fmt.Println(name) // Output: // `John-Smith` WithGender(gender Gender) NameGenerator // WithPrefix generates a name with a prefix. // // Example: // generator := namegenerator.NewGenerator().WithPrefix("Mr. ") // name := generator.Generate() // fmt.Println(name) // Output: // `Mr. John-Smith` WithPrefix(prefix string) NameGenerator // WithSuffix generates a name with a suffix. // // Example: // generator := namegenerator.NewGenerator().WithSuffix("@gmail.com") // name := generator.Generate() // fmt.Println(name) // Output: // `John-Smith@gmail.com` WithSuffix(suffix string) NameGenerator // WithRandomString generates a name with a random string. // // Example: // generator := namegenerator.NewGenerator().WithRandomString(5) // name := generator.Generate() // fmt.Println(name) // Output: // `John-Smith-abcde` WithRandomString(lenOfRandomString int) NameGenerator }
NameGenerator is an interface for generating names.
func NewGenerator ¶ added in v1.3.0
func NewGenerator() NameGenerator
NewGenerator returns a new NameGenerator.
Example to generate general names:
generator := namegenerator.NewGenerator()
Example to generate male names:
generator := namegenerator.NewGenerator().WithGender(namegenerator.Male)
Example to generate female names:
generator := namegenerator.NewGenerator().WithGender(namegenerator.Female)
Example to generate non-binary names:
generator := namegenerator.NewGenerator().WithGender(namegenerator.NonBinary)
Example to generate names with a prefix:
generator := namegenerator.NewGenerator().WithPrefix("Mr. ")
Example to generate names with a suffix:
generator := namegenerator.NewGenerator().WithSuffix("@gmail.com")
Example to generate names with a random string:
generator := namegenerator.NewGenerator().WithRandomString(5)
type Options ¶ added in v1.4.0
type Options func(*nameGenerator)
func WithGender ¶ added in v1.4.0
WithGender generates a name based on the gender.
func WithPrefix ¶ added in v1.4.0
WithPrefix generates a name with a prefix.
func WithRandomString ¶ added in v1.4.0
WithRandomString generates a name with a random string.
func WithSuffix ¶ added in v1.4.0
WithSuffix generates a name with a suffix.
Click to show internal directories.
Click to hide internal directories.