gen

package
v3.35.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: Apache-2.0, Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Animals = []string{}/* 626 elements not displayed */

Functions

This section is empty.

Types

type Gen

type Gen struct {
	R *rand.Rand
	// contains filtered or unexported fields
}

func New

func New(opts ...Opt) *Gen

New creates a new *Gen

func (*Gen) AlphaLower

func (g *Gen) AlphaLower(bs []byte)

func (*Gen) AlphaUpper

func (g *Gen) AlphaUpper(bs []byte)

func (*Gen) Set

func (g *Gen) Set(min uint64, max uint64, typicalCardinality uint64) map[uint64]struct{}

Set generates a random set of integers between min and max (inclusive). The mean cardinality of the set is specified by typicalCardinality.

func (*Gen) StringFromList

func (g *Gen) StringFromList(list []string) string

StringFromList returns a random string from the list each with uniform probability

func (*Gen) StringFromListWeighted

func (g *Gen) StringFromListWeighted(list []string) string

StringFromListWeighted returns a random string from the list weighted toward the items earlier in the list.

func (*Gen) StringSliceFromList

func (g *Gen) StringSliceFromList(input []string, list []string) []string

StringSliceFromList repopulates input with a random number of items from list. If input does not have enough capacity it may return a new list. There may be repeat items, there may be 0 items, there will never be more items than the length of list.

func (*Gen) StringSliceFromListWeighted

func (g *Gen) StringSliceFromListWeighted(input []string, list []string, s, v float64) []string

StringSliceFromListWeighted picks between 0 and upto items from list randomly, but zipfian weighted toward items earlier in list. It will try to re-use input, but may allocate a new list if needed.

type Opt

type Opt func(g *Gen)

func OptGenSeed

func OptGenSeed(s int64) Opt

OptGenSeed is a functional option for providing a seed to Gen.

Jump to

Keyboard shortcuts

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