random

package
v0.0.0-...-5720ada Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package random provides an interface on top of math/rand to ease testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() *rand.Rand

New returns a rand.Rand seeded with the current time with nanoseconds precision.

func NewDummy

func NewDummy() *rand.Rand

NewDummy returns a rand.Rand seeded with 0.

func NewDummySource

func NewDummySource() rand.Source

NewDummySource returns a rand.Source seeded with 0.

func NewLocked

func NewLocked() *rand.Rand

NewLocked returns a rand.Rand with a random source protected by a mutex. To be used for concurrent access.

func NewLockedSource

func NewLockedSource(src rand.Source) rand.Source

NewLockedSource wraps the Source with a mutex. To be used for concurrent access.

func NewMockSource

func NewMockSource() *mockSource

NewMockSource returns a mocked rand.Source. Configure each call before using.

func NewSeeded

func NewSeeded(seed int64) *rand.Rand

NewSeeded returns a seeded rand.Rand.

func NewSeededSource

func NewSeededSource(seed int64) rand.Source

NewSeededSource returns a seeded rand.Source, just like the rand package. Provided for API completeness

func NewSource

func NewSource() rand.Source

NewSource returns a rand.Source seeded with the current time with nanoseconds precision.

func NewStatic

func NewStatic(value int64) *rand.Rand

NewStatic returns a rand.Rand that always returns the seeded value. Useful for tests.

func NewStaticSource

func NewStaticSource(value int64) rand.Source

NewStaticSource returns a rand.Source that always returns the seeded value. Useful for tests.

Types

This section is empty.

Jump to

Keyboard shortcuts

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