Documentation
¶
Index ¶
- func Alpha(n int) string
- func Bool() bool
- func Byte() byte
- func Choice[T any](slice []T) T
- func Date(min, max time.Time) time.Time
- func Duration(min, max time.Duration) time.Duration
- func FromCharset(n int, charset string) string
- func Number[T Num](min, max T) T
- func Numeric(n int) string
- func Password(n int, opts PasswordOptions) string
- func Sign() int
- func String(n int) string
- type Num
- type PasswordOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Alpha ¶
Alpha returns a random string of letters of length n includes both lowercase and uppercase letters
func Choice ¶
func Choice[T any](slice []T) T
Choice picks a random element from a non-empty slice Panics if the slice is empty.
func Date ¶
Date returns a random time.Time between min and max (inclusive) Safely swaps min and max
func Duration ¶
Duration returns a random time.Duration between min and max (inclusive) Safely swaps min and max
func FromCharset ¶
FromCharset returns a random string from your specific charset
func Number ¶
func Number[T Num](min, max T) T
Number returns a random number in the range [min, max] inclusive for int and [min, max) for floats Safely swaps max & min Limitations: - uses math/rand (not safe for concurrent use, not for security-sensitive use) - overflow warning on extreme ranges
func Password ¶
func Password(n int, opts PasswordOptions) string
Password generates a random password of length n according to options. Panic if no charsets selected (or effectively not selected - e.g: excluding all options)