Documentation
¶
Overview ¶
Utility package for random operations.
Index ¶
- Constants
- func ERand(len int) string
- func GenNo(prefix string) string
- func GenNoL(prefix string, len int) string
- func Pick(set []rune) rune
- func RandAlpha(n int) string
- func RandLowerAlpha(n int) string
- func RandLowerAlphaNumeric(n int) string
- func RandLowerAlphaNumeric16() string
- func RandNum(n int) string
- func RandOp(ops ...func())
- func RandPick[T any](s []T) T
- func RandRune(n int, set []rune) string
- func RandStr(n int) string
- func RandUpperAlpha(n int) string
- func RandUpperAlphaNumeric(n int) string
- func ShuffleRunes(letters []rune, times int) []rune
- func ShuffleStr(letters string, times int) string
- func WeightedRandPick[T interface{ ... }](s []T) T
- type WeightedItem
Constants ¶
const (
DEFAULT_LEN = 35
)
Variables ¶
This section is empty.
Functions ¶
func RandAlpha ¶
Generate random alphabetic string with specified length
the generated string will contains [a-zA-Z]
func RandLowerAlpha ¶
Generate random alphabetic, lowercase string with specified length
the generated string will contains [a-z]
func RandLowerAlphaNumeric ¶
Generate random alphabetic, lowercase string with specified length
the generated string will contains [a-z0-9]
func RandLowerAlphaNumeric16 ¶
func RandLowerAlphaNumeric16() string
Same as RandLowerAlphaNumeric(16) but with less allocation.
func RandNum ¶
Generate random numeric string with specified length
the generated string will contains [0-9]
func RandStr ¶
Generate random string with specified length
the generated string will contains [a-zA-Z0-9]
ERand() is preferred for higher entrophy
func RandUpperAlpha ¶
Generate random alphabetic, uppercase string with specified length
the generated string will contains [A-Z]
func RandUpperAlphaNumeric ¶
Generate random alphabetic, uppercase string with specified length
the generated string will contains [A-Z0-9]
func ShuffleRunes ¶
func ShuffleStr ¶
func WeightedRandPick ¶
func WeightedRandPick[T interface{ GetWeight() float64 }](s []T) T
Types ¶
type WeightedItem ¶
func (WeightedItem[T]) GetWeight ¶
func (w WeightedItem[T]) GetWeight() float64