randx

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Rand

type Rand struct {
	rand.Rand
}

Rand is a rand with more useful methods

func New

func New() *Rand

New return a new Rand using timestamp as seed

func NewWithSeed

func NewWithSeed(seed int64) *Rand

NewWithSeed return a new Rand using seed

func (*Rand) Int32Within

func (r *Rand) Int32Within(bound int32) int32

Int32Within return a random int32 value within range [0, bound) if bound larger than 0, Panics with an error if bound is less than or equals 0.

func (*Rand) Int64Within

func (r *Rand) Int64Within(bound int64) int64

Int64Within return a random int64 value within range [0, bound). If bound is less than or equals with 0, panics with an error

func (*Rand) IntBetween

func (r *Rand) IntBetween(low int, high int) int

IntBetween return a random value within range [low, high) if low less than high, The func panics an error if low is larger than or equals high, or high-low overflows int.

func (*Rand) IntWithin

func (r *Rand) IntWithin(bound int) int

IntWithin return a random value within range [0, bound) if bound larger than 0. panics bound is less than or equals 0.

Jump to

Keyboard shortcuts

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