unsafe

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: Apache-2.0 Imports: 3 Imported by: 19

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes

func Bytes(n int) []byte

func Int

func Int() int

func Int63

func Int63() int64

func Seed

func Seed(seed int64)

func Str

func Str(length int) string

Types

type Rand

type Rand struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Rand is a prng, that is seeded with OS randomness. The OS randomness is obtained from crypto/rand, however none of the provided methods are suitable for cryptographic usage. They all utilize math/rand's prng internally.

All of the methods here are suitable for concurrent use. This is achieved by using a mutex lock on all of the provided methods.

func NewRand

func NewRand() *Rand

func (*Rand) Bytes

func (r *Rand) Bytes(n int) []byte

Bytes returns n random bytes generated from the internal prng.

func (*Rand) Int

func (r *Rand) Int() int

func (*Rand) Int63

func (r *Rand) Int63() int64

func (*Rand) Seed

func (r *Rand) Seed(seed int64)

func (*Rand) Str

func (r *Rand) Str(length int) string

Str constructs a random alphanumeric string of given length.

Jump to

Keyboard shortcuts

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