random

package
v0.0.0-...-b349366 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2020 License: MIT Imports: 5 Imported by: 32

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes

func Bytes(n int) []byte

Bytes generates a random byte slice of length n

func FillBytes

func FillBytes(p []byte)

FillBytes fills the byte slice with random bytes. It does not use an intermediate buffer

func Intn

func Intn(n int) int

Intn returns a random number in the range [0,n)

func String

func String(n int) string

String returns a random string of length n, it uses the characters of base64.URLEncoding

Types

type Interface

type Interface interface {
	Intn(n int) int
	String(n int) string
	Bytes(n int) []byte
	FillBytes(p []byte)
}

Interface for random

func New

func New() Interface

New returns a new Random, in most cases you can also just use the global funcs

type TTNRandom

type TTNRandom struct {
	Source io.Reader
}

TTNRandom is used as a wrapper around crypto/rand

func (*TTNRandom) Bytes

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

func (*TTNRandom) FillBytes

func (r *TTNRandom) FillBytes(p []byte)

func (*TTNRandom) Intn

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

func (*TTNRandom) String

func (r *TTNRandom) String(n int) string

Jump to

Keyboard shortcuts

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