package module
v0.3.0 Latest Latest

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

Go to latest
Published: Oct 28, 2023 License: MIT Imports: 4 Imported by: 0




Happening by or depending on chance in Golang

Go Reference Docs Reference Go Report Card License

Dieharder source summary

SEED: 1234567
Test data: 229GiB
Name Performance
smaller is better
Time PASS WEAK FAIL Total Draw test References
Built In 3.183 / 3.245 / 3.307 35:33 112 2 0 114 img Ref
PCG-XSL-RR 5.337 / 5.861 / 6.279 36:12 112 2 0 114 img Ref
Small Prng 2.494 / 2.607 / 2.934 37:49 114 0 0 114 img Ref1,
Xoshiro256++ 2.838 / 3.102 / 3.360 39:35 112 2 0 114 img Ref
Xoshiro256** 2.678 / 2.935 / 3.186 37:01 108 6 0 114 img Ref
SplitMix64 2.282 / 2.32 / 2.411 38:06 113 1 0 114 img Ref

Detailed results please check in the dieharder-source folder.

Few more RNG and test results can be found in rngset repo.


go test -bench=. -timeout 30m ./fluky_testing

Execute dieharder tests

Check the README.md.

How to increase version
  • commit all required changes
  • git tag <version - v0.0.2>
  • git push origin --tags
  • done - check docs on pkg.go.dev
  • install by go get -u github.com/Pencroff/fluky





This section is empty.


This section is empty.


This section is empty.


type BoolOptions added in v0.0.5

type BoolOptions struct {
	// contains filtered or unexported fields

type BoolOptionsFn added in v0.0.5

type BoolOptionsFn func(b *BoolOptions)

func WithLikelihood added in v0.0.5

func WithLikelihood(v float64) BoolOptionsFn

WithLikelihood makes closure with passed likelihood for options object

type FloatOptions added in v0.0.5

type FloatOptions struct {
	// contains filtered or unexported fields

type FloatOptionsFn added in v0.0.5

type FloatOptionsFn func(f *FloatOptions)

func WithFloatRange added in v0.0.5

func WithFloatRange(min, max float64) FloatOptionsFn

WithFloatRange configure min and max values for float random

func WithPrecision added in v0.0.5

func WithPrecision(precision int8) FloatOptionsFn

WithPrecision configure max precision for float random

type Fluky

type Fluky struct {
	// contains filtered or unexported fields

func NewFluky

func NewFluky(r RandomGenerator) *Fluky

NewFluky create new Fluky instance and return pointer to it

func (*Fluky) Bool added in v0.0.5

func (f *Fluky) Bool(opts ...BoolOptionsFn) bool

Bool returns random bool value with 0.5 likelihood by default Options changing likelihood of returned value

func (*Fluky) Float added in v0.0.5

func (f *Fluky) Float(opts ...FloatOptionsFn) float64

Float random float value from range [min, max) by default min = 0, max = 1 max precision = 20

func (*Fluky) Float64 added in v0.0.5

func (f *Fluky) Float64() float64

Float64 returns random float64 value in range [0, 1)

func (*Fluky) Int63 added in v0.0.5

func (f *Fluky) Int63() int64

Int63 returns random int64 value in range [0, 2^63)

func (*Fluky) Integer added in v0.0.5

func (f *Fluky) Integer(opts ...IntegerOptionsFn) int

Integer random integer value from range [min, max] from −(2^62) to 2^62 − 1 by default (int64) to avoid overflow for int64 positive range using values out of this range doesn't warranty that result will be in range [min, max]

func (Fluky) PickOne added in v0.0.4

func (f Fluky) PickOne(values []interface{}) (idx int, value interface{})

PickOne choose random value from slice and return index and value

func (*Fluky) Seed

func (f *Fluky) Seed(v int64)

Seed internal RNG, reset seed value

func (*Fluky) String added in v0.0.5

func (f *Fluky) String(opts ...StringOptionsFn) string

String returns random string configured by default options

func (*Fluky) Uint64 added in v0.0.5

func (f *Fluky) Uint64() uint64

Uint64 returns random uint64 value

func (*Fluky) Weighted

func (f *Fluky) Weighted(values []interface{}, weights []uint) interface{}

Weighted choose random value base on weights

type IntegerOptions added in v0.0.5

type IntegerOptions struct {
	// contains filtered or unexported fields

type IntegerOptionsFn added in v0.0.5

type IntegerOptionsFn func(i *IntegerOptions)

func WithIntRange added in v0.0.5

func WithIntRange(min, max int) IntegerOptionsFn

WithIntRange configure min and max values for integer random

type RandomGenerator added in v0.1.0

type RandomGenerator interface {
	Seed(v int64)
	Int63() int64
	Uint32() uint32
	Uint64() uint64
	Int31() int32
	Int() int
	Int63n(n int64) int64
	Int31n(n int32) int32
	Intn(n int) int
	Float64() float64
	Float32() float32
	Perm(n int) []int
	Shuffle(n int, swap func(i, j int))
	Read(p []byte) (int, error)

RandomGenerator is interface declare methods of std lib rand.Rand it used for testing purpose

type RngMock

type RngMock struct {

func (*RngMock) Float32 added in v0.1.0

func (r *RngMock) Float32() float32

func (*RngMock) Float64

func (r *RngMock) Float64() float64

func (*RngMock) Int added in v0.1.0

func (r *RngMock) Int() int

func (*RngMock) Int31 added in v0.1.0

func (r *RngMock) Int31() int32

func (*RngMock) Int31n added in v0.1.0

func (r *RngMock) Int31n(n int32) int32

func (*RngMock) Int63 added in v0.0.5

func (r *RngMock) Int63() int64

func (*RngMock) Int63n added in v0.1.0

func (r *RngMock) Int63n(n int64) int64

func (*RngMock) Intn added in v0.1.0

func (r *RngMock) Intn(n int) int

func (*RngMock) Perm added in v0.1.0

func (r *RngMock) Perm(n int) []int

func (*RngMock) Read added in v0.1.0

func (r *RngMock) Read(p []byte) (int, error)

func (*RngMock) Seed

func (r *RngMock) Seed(v int64)

func (*RngMock) Shuffle added in v0.1.0

func (r *RngMock) Shuffle(n int, swap func(i int, j int))

func (*RngMock) Uint32 added in v0.1.0

func (r *RngMock) Uint32() uint32

func (*RngMock) Uint64

func (r *RngMock) Uint64() uint64

type StringOptions added in v0.0.5

type StringOptions struct {
	// contains filtered or unexported fields

type StringOptionsFn added in v0.0.5

type StringOptionsFn func(s *StringOptions)

func AndAlphabet added in v0.0.5

func AndAlphabet(alphabet string) StringOptionsFn

AndAlphabet extend configured alphabet for options object

func AndGreekLowerAlphabet added in v0.2.0

func AndGreekLowerAlphabet() StringOptionsFn

AndGreekLowerAlphabet extend configured alphabet with greek lower characters

func AndGreekUpperAlphabet added in v0.2.0

func AndGreekUpperAlphabet() StringOptionsFn

AndGreekUpperAlphabet extend configured alphabet with greek upper characters

func AndLatinLowerAlphabet added in v0.2.0

func AndLatinLowerAlphabet() StringOptionsFn

AndLatinLowerAlphabet extend configured alphabet with latin lower characters

func AndLatinUpperAlphabet added in v0.2.0

func AndLatinUpperAlphabet() StringOptionsFn

AndLatinUpperAlphabet extend configured alphabet with latin upper characters

func AndNumericAlphabet added in v0.0.5

func AndNumericAlphabet() StringOptionsFn

AndNumericAlphabet extend configured alphabet with numbers

func AndSymbolsAlphabet added in v0.0.5

func AndSymbolsAlphabet() StringOptionsFn

AndSymbolsAlphabet extend configured alphabet with symbols

func AndSymbolsUrlSafeAlphabet added in v0.0.5

func AndSymbolsUrlSafeAlphabet() StringOptionsFn

AndSymbolsUrlSafeAlphabet extend configured alphabet with symbols

func AndUkrainianLowerAlphabet added in v0.2.0

func AndUkrainianLowerAlphabet() StringOptionsFn

AndUkrainianLowerAlphabet extend configured alphabet with ukrainian lower characters

func AndUkrainianUpperAlphabet added in v0.2.0

func AndUkrainianUpperAlphabet() StringOptionsFn

AndUkrainianUpperAlphabet extend configured alphabet with ukrainian upper characters

func WithAlphabet added in v0.0.5

func WithAlphabet(alphabet string) StringOptionsFn

WithAlphabet makes closure with passed alphabet for options object

func WithGreekLowerAlphabet added in v0.2.0

func WithGreekLowerAlphabet() StringOptionsFn

WithGreekLowerAlphabet configure greek lower alphabet

func WithGreekUpperAlphabet added in v0.2.0

func WithGreekUpperAlphabet() StringOptionsFn

WithGreekUpperAlphabet configure greek upper alphabet

func WithHexAlphabet added in v0.0.5

func WithHexAlphabet() StringOptionsFn

WithHexAlphabet configure hex alphabet

func WithLatinLowerAlphabet added in v0.2.0

func WithLatinLowerAlphabet() StringOptionsFn

WithLatinLowerAlphabet configure latin lower alphabet

func WithLatinUpperAlphabet added in v0.2.0

func WithLatinUpperAlphabet() StringOptionsFn

WithLatinUpperAlphabet configure latin upper alphabet

func WithLength added in v0.0.5

func WithLength(v uint8) StringOptionsFn

WithLength makes closure with passed length for options object

func WithLengthRange added in v0.0.5

func WithLengthRange(min, max uint8) StringOptionsFn

WithLengthRange makes closure with passed min and max length for options object

func WithNumericAlphabet added in v0.0.5

func WithNumericAlphabet() StringOptionsFn

WithNumericAlphabet configure numeric alphabet

func WithSymbolsAlphabet added in v0.0.5

func WithSymbolsAlphabet() StringOptionsFn

WithSymbolsAlphabet configure symbols alphabet

func WithSymbolsUrlSafeAlphabet added in v0.0.5

func WithSymbolsUrlSafeAlphabet() StringOptionsFn

WithSymbolsUrlSafeAlphabet configure safe for url usage alphabet symbols

func WithUkrainianLowerAlphabet added in v0.2.0

func WithUkrainianLowerAlphabet() StringOptionsFn

WithUkrainianLowerAlphabet configure ukrainian lower alphabet

func WithUkrainianUpperAlphabet added in v0.2.0

func WithUkrainianUpperAlphabet() StringOptionsFn

WithUkrainianUpperAlphabet configure ukrainian upper alphabet

func WithUrlSafeAlphabet added in v0.0.5

func WithUrlSafeAlphabet() StringOptionsFn

WithUrlSafeAlphabet configure safe for url usage alphabet


Path Synopsis

Jump to

Keyboard shortcuts

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