randomizer

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2022 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPredictableSeed

func GetPredictableSeed(instance, session int) int64

GetPredictableSeed Get predictable seed for instance session combination, to be used for randomizers in testing and trend measurements

func GetPredictableSeedUInt64

func GetPredictableSeedUInt64(instance, session uint64) int64

GetPredictableSeedUInt64 Get predictable seed for instance session combination, to be used for randomizers in testing and trend measurements

Types

type Randomizer

type Randomizer struct {
	// contains filtered or unexported fields
}

Randomizer overlord randomizer

func NewRandomizer

func NewRandomizer() *Randomizer

NewRandomizer new randomizer seeded with time.now

func NewSeededRandomizer

func NewSeededRandomizer(seed int64) *Randomizer

NewSeededRandomizer new seeded randomizer

func (*Randomizer) Float64 added in v0.14.12

func (rnd *Randomizer) Float64() float64

Float64 returns, as a float64, a pseudo-random number in the half-open interval [0.0,1.0).

func (*Randomizer) Rand

func (rnd *Randomizer) Rand(max int) int

Rand returns result from Intn using current randomizer instance

func (*Randomizer) Rand32

func (rnd *Randomizer) Rand32(max int32) int32

Rand32 returns result from Int32n using current randomizer instance

func (*Randomizer) RandBytes

func (rnd *Randomizer) RandBytes(size int) ([]byte, error)

RandBytes random byte array

func (*Randomizer) RandDuration

func (rnd *Randomizer) RandDuration(minDuration, maxDuration time.Duration) (time.Duration, error)

RandDuration random duration up to max

func (*Randomizer) RandInt

func (rnd *Randomizer) RandInt(ints []int) (int, error)

RandInt return random int from list

func (*Randomizer) RandIntPos

func (rnd *Randomizer) RandIntPos(ints []int) (int, int, error)

RandIntPos return random int value and position from list (value, pos)

func (*Randomizer) RandRune added in v0.14.5

func (rnd *Randomizer) RandRune(runes []rune) rune

RandRune from rune array

func (*Randomizer) RandString

func (rnd *Randomizer) RandString(strings []string) (string, error)

RandString return random string from list

func (*Randomizer) RandWeighted

func (rnd *Randomizer) RandWeighted(w []Weighted) (string, error)

RandWeighted randomize using Weighted interface

func (*Randomizer) RandWeightedInt

func (rnd *Randomizer) RandWeightedInt(weights []int) (int, error)

RandWeightedInt randomize based on weight

type Weighted

type Weighted interface {
	GetKey() string
	GetWeight() int
}

Weighted Interface used by random weighted functions

Jump to

Keyboard shortcuts

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