Documentation
¶
Overview ¶
Package seed provides seeds used to decide behavior during query generation.
For example, a clause may decide to return a value if the seed returns an even value. Else it decides to returns no value.
Index ¶
- type Seed
- func (s *Seed) BooleanWithProbability(probability float64) bool
- func (s *Seed) GetByte() byte
- func (s *Seed) GetByteString() []byte
- func (s *Seed) GetRandomInt64() int64
- func (s *Seed) GetRandomIntn(n int) int
- func (s *Seed) GetRandomPositiveInt64() int64
- func (s *Seed) RandomBoolean() bool
- func (s *Seed) RandomStringFromChoice(choice ...string) string
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Seed ¶
type Seed struct {
// contains filtered or unexported fields
}
A Seed has the GetByte function, which can be used by clauses to guide generation.
func GetPregeneratedByteString ¶
GetPregeneratedByteString returns a seed which returns the bytes passed in the slice of bytes in order. If the passed slice is too short, it starts randomly generating future bytes after exhausting the slice of bytes.
Example ¶
Test that the pregenerated byte string returns the passed bytes in order
package main import ( "fmt" "github.com/Anon10214/dinkel/seed" ) func main() { byteString := []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9} seed := seed.GetPregeneratedByteString(byteString) for range byteString { fmt.Printf("%d ", seed.GetByte()) } }
Output: 0 1 2 3 4 5 6 7 8 9
func GetRandomByteString ¶
func GetRandomByteString() *Seed
GetRandomByteString returns a seed returning randomly generated bytes.
func GetRandomByteStringWithSource ¶
GetRandomByteStringWithSource returns a seed returning bytes which get read from the passed source.
func (*Seed) BooleanWithProbability ¶
BooleanWithProbability uses the passed seed to generate a boolean with the value "true" with the probability provided. Assumes that 0 <= probability <= 1
func (*Seed) GetByteString ¶
GetByteString returns the string of bytes which have been generated
func (*Seed) GetRandomInt64 ¶
GetRandomInt64 returns a random int64 generated with the seed
func (*Seed) GetRandomIntn ¶
GetRandomIntn returns a random int in [0, n)
func (*Seed) GetRandomPositiveInt64 ¶
GetRandomPositiveInt64 returns a random positive int64 generated with the seed
func (*Seed) RandomBoolean ¶
RandomBoolean returns true with probability 0.5, else false
func (*Seed) RandomStringFromChoice ¶
RandomStringFromChoice takes in an arbitrary amount of strings and returns one of them randomly.