random

package
v1.8.4 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Randomizer

type Randomizer struct {
	mathRand.Rand
}

func New

func New() *Randomizer

New returns a preseeded randomizer

func (*Randomizer) Bytes

func (r *Randomizer) Bytes(n int) ([]byte, error)

Bytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func (*Randomizer) Code

func (r *Randomizer) Code() string

Code returns a random code

func (*Randomizer) Number

func (r *Randomizer) Number(n int) int

Number generates a number between 0 and n

func (*Randomizer) NumberBetween

func (r *Randomizer) NumberBetween(n int, m int) int

NumberBetween returns a random number between n and m

func (*Randomizer) Port

func (r *Randomizer) Port() (int, error)

Port asks the kernel for an available port

func (*Randomizer) String

func (r *Randomizer) String(s int) (string, error)

String returns a URL-safe, base64 encoded securely generated random string.

Jump to

Keyboard shortcuts

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