utils

package
v0.0.0-...-7ac062e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func AllNameGenderDescriptions

func AllNameGenderDescriptions() ([]string, error)

func AllNameGenderDescriptionsWithKeys

func AllNameGenderDescriptionsWithKeys() ([]string, error)

func AllNameGenderKeys

func AllNameGenderKeys() ([]string, error)

func FormatNumberWithDelimiter

func FormatNumberWithDelimiter(num int, delimiter string) string

func GeneratePassword

func GeneratePassword(passwordLength int) string

PasswordGenerator Source: https://www.twilio.com/en-us/blog/generate-passwords-go

func IntRangeFromString

func IntRangeFromString(input string, min int, max int) (int, int, error)

func OpenFile

func OpenFile(filepath string) error

func ProperNounCase

func ProperNounCase(input string) string

ProperNounCase changes the case to use proper noun case in English, e.g. JOHN -> John, sally -> Sally

func RandStringBytesMaskImprSrc

func RandStringBytesMaskImprSrc(n int) string

func RandomColour

func RandomColour() string

func RandomColours

func RandomColours(n int) []string

func RandomHex

func RandomHex(length int) (string, error)

func RandomItemFromList

func RandomItemFromList[T any](items []T) (*T, error)

RandomItemFromList

func RandomNumberBetweenRange

func RandomNumberBetweenRange(min int, max int) int

func TrimEmptyLines

func TrimEmptyLines(input string) string

func WithFemaleNamesList

func WithFemaleNamesList(namesList string) func(*nameService)

func WithLastNamesList

func WithLastNamesList(namesList string) func(*nameService)

func WithMaleNamesList

func WithMaleNamesList(namesList string) func(*nameService)

func WithUnisexNamesList

func WithUnisexNamesList(namesList string) func(*nameService)

Types

type NameGender

type NameGender int
const (
	NameGenderUnisex NameGender = iota
	NameGenderFemale
	NameGenderMale
	NameGenderAny
)

func NameGenderFromString

func NameGenderFromString(value string) NameGender

func (NameGender) Description

func (g NameGender) Description() (string, error)

func (NameGender) DescriptionWithKey

func (g NameGender) DescriptionWithKey() (string, error)

func (NameGender) Key

func (g NameGender) Key() (string, error)

type NameService

type NameService interface {
	GetFirstNamesFemale() []string
	GetFirstNamesMale() []string
	GetFirstNamesUnisex() []string
	GetLastNames() []string

	RandomFirstNameFemale() (string, error)
	RandomFirstNameMale() (string, error)
	RandomFirstNameUnisex() (string, error)
	RandomFirstNameAny() (string, error)
	RandomFirstName(NameGender) (string, error)
	RandomLastName() (string, error)
}

func NewNameService

func NewNameService(options ...func(*nameService)) NameService

func NewPopulatedService

func NewPopulatedService(options ...func(*nameService)) NameService

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL