Documentation ¶
Index ¶
- func AlphaNumericStrBetween[T constraints.Integer](minLength T, maxLength T) string
- func AlphaStrBetween[T constraints.Integer](minLength T, maxLength T) string
- func Bytes[T constraints.Integer](len T) []byte
- func BytesBetween[T constraints.Integer](lower T, upper T) []byte
- func HexStr[T constraints.Integer](len T) string
- func I64Between[T constraints.Integer](lower T, upper T) int64
- func PosI64() int64
- func Sample[T1 any, T2 constraints.Integer](source []T1, count T2, withRedraw ...bool) []T1
- func Str[T constraints.Integer](len T) string
- func StrBetween[T constraints.Integer](minLength T, maxLength T) string
- func Time() time.Time
- type BoolGen
- type DistinctStrGen
- type DistrGen
- type I64Gen
- type StringGen
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AlphaNumericStrBetween ¶
func AlphaNumericStrBetween[T constraints.Integer](minLength T, maxLength T) string
AlphaNumericStrBetween returns a random alphanumeric string of random length in the given limits (inclusive)
func AlphaStrBetween ¶
func AlphaStrBetween[T constraints.Integer](minLength T, maxLength T) string
AlphaStrBetween returns a random alphabetical string of random length in the given limits (inclusive)
func Bytes ¶
func Bytes[T constraints.Integer](len T) []byte
Bytes returns a random slice of bytes of the specified length
func BytesBetween ¶
func BytesBetween[T constraints.Integer](lower T, upper T) []byte
BytesBetween returns a random byte slice of random length in the given limits (upper exclusive)
func HexStr ¶
func HexStr[T constraints.Integer](len T) string
HexStr returns a random hex string of given length
func I64Between ¶
func I64Between[T constraints.Integer](lower T, upper T) int64
I64Between returns a random integer between lower (inclusive) and upper (exclusive). It panics if upper <= lower.
func Sample ¶
func Sample[T1 any, T2 constraints.Integer](source []T1, count T2, withRedraw ...bool) []T1
Sample returns a new slice with a uniform sample of elements from the source slice. If withRedraw is true, the same element can be chosen multiple times.
func Str ¶
func Str[T constraints.Integer](len T) string
Str returns a random string of given length
func StrBetween ¶
func StrBetween[T constraints.Integer](minLength T, maxLength T) string
StrBetween returns a random string of random length in the given limits (inclusive)
Types ¶
type BoolGen ¶
type BoolGen struct {
// contains filtered or unexported fields
}
BoolGen represents an random bool generator. Call Stop when done so dangling goroutines can be cleaned up.
type DistinctStrGen ¶
type DistinctStrGen struct { StringGen // contains filtered or unexported fields }
DistinctStrGen represents an random string generator which returns distinct strings. Call Stop when done so dangling goroutines can be cleaned up.
func (DistinctStrGen) Next ¶
func (g DistinctStrGen) Next() string
Next returns a single random string that is distinct from all previously generated strings.
func (DistinctStrGen) Take ¶
func (g DistinctStrGen) Take(count int) []string
Take returns a slice of distinct random strings of the given length.
type DistrGen ¶
type DistrGen struct {
// contains filtered or unexported fields
}
DistrGen represents a probability distribution that can be sampled
func Distr ¶
func Distr[T constraints.Integer](n T) DistrGen
Distr generates a new probability distribution with n states of random probability
type I64Gen ¶
type I64Gen struct {
// contains filtered or unexported fields
}
I64Gen represents an random integer generator to generate a sequence of integers with the same properties. Call Stop when done so dangling goroutines can be cleaned up.
func I64GenBetween ¶
func I64GenBetween[T constraints.Integer](lower T, upper T) I64Gen
I64GenBetween returns a random integer generator for numbers between lower (inclusive) and upper (exclusive). It panics if upper <= lower.
func PInt64Gen ¶
func PInt64Gen() I64Gen
PInt64Gen returns a random integer generator for positive integers.
type StringGen ¶
type StringGen struct {
// contains filtered or unexported fields
}
StringGen represents an random string generator. Call Stop when done so dangling goroutines can be cleaned up.
func AlphaNumericStrings ¶
func AlphaNumericStrings[T constraints.Integer](minLength T, maxLength T) StringGen
AlphaNumericStrings returns a random string generator that produces strings from the alphanumeric characters of random length in the given limits (inclusive)
func AlphaStrings ¶
func AlphaStrings[T constraints.Integer](minLength T, maxLength T) StringGen
AlphaStrings returns a random string generator that produces strings from the alphabetical characters of random length in the given limits (inclusive)
func HexStrings ¶
func HexStrings[T constraints.Integer](length T) StringGen
HexStrings returns a random hex string generator that produces hex strings with given length
func Strings ¶
func Strings[T constraints.Integer](minLength T, maxLength T) StringGen
Strings returns a random string generator that produces strings from the default alphabet of random length in the given limits (inclusive)
func (StringGen) Distinct ¶
func (g StringGen) Distinct() DistinctStrGen
Distinct returns a new unique string
func (StringGen) WithAlphabet ¶
WithAlphabet returns a random string generator that produces strings from the given alphabet of length between the given limits (inclusive)