randomizer

package module
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: Apache-2.0 Imports: 4 Imported by: 3

README

randomizer

Go Reference Go Report Card GitHub License

Fast and thread-safe random data generator package written in Go

Installation

Use go get -u:

go get -u github.com/colduction/randomizer@latest

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultHashPool = NewHashPool(50)

DefaultHashPool is a globally accessible hashPool with a preallocated size.

View Source
var Network network
View Source
var Word word

Functions

func Float32 added in v1.4.0

func Float32() float32

Float32 generates a random 32-bit float value in the range [0, 1) using the hashPool. It retrieves a random 32-bit number from the hash pool, masks the result to retain only the lower 24 bits, and converts it into a float32 by dividing by 2^24 to normalize the value into the range [0, 1).

func Float64 added in v1.4.0

func Float64() float64

Float64 generates a random 64-bit float value in the range [0, 1) using the hashPool. It retrieves a random 64-bit number from the hash pool, masks the result to retain only the lower 53 bits, and converts it into a float64 by dividing by 2^53 to normalize the value into the range [0, 1).

func Int added in v1.4.0

func Int[T SignedIntegers]() T

Int generates a random signed integer of type T.

func IntInterval added in v1.4.0

func IntInterval[T SignedIntegers](min, max T) T

IntInterval generates a random signed integer of type T within a specified range.

func NewHashPool added in v1.1.0

func NewHashPool(size int) *hashPool

NewHashPool creates a new hashPool with the specified size. If size is 0, it returns nil. The pool will preallocate size maphash.Hash objects for reuse.

func Uint added in v1.4.0

func Uint[T UnsignedIntegers]() T

Uint generates a random unsigned integer of type T.

func UintInterval added in v1.4.0

func UintInterval[T UnsignedIntegers](min, max T) T

UintInterval generates a random unsigned integer of type T within a specified range.

Types

type Integers added in v1.1.0

type Integers interface {
	SignedIntegers | UnsignedIntegers
}

type MulticastScope added in v1.3.0

type MulticastScope uint8

ref: https://datatracker.ietf.org/doc/html/rfc3513#section-2.7

const (
	InterfaceLocalScope MulticastScope = 0x1
	LinkLocalScope      MulticastScope = 0x2
	AdminLocalScope     MulticastScope = 0x4
	SiteLocalScope      MulticastScope = 0x5
	OrgLocalScope       MulticastScope = 0x8
	GlobalScope         MulticastScope = 0xE
)

type SignedIntegers added in v1.1.0

type SignedIntegers interface {
	~int8 | ~int16 | ~int | ~int32 | ~int64
}

type UnicastType added in v1.3.0

type UnicastType uint8

ref: https://datatracker.ietf.org/doc/html/rfc3513#section-2.5

const (
	GlobalType UnicastType = iota + 1
	LinkLocalType
	SiteLocalType
	UniqueLocalType
	PrivateType UnicastType = UniqueLocalType
)

type UnsignedIntegers added in v1.1.0

type UnsignedIntegers interface {
	~uint8 | ~uint16 | ~uint | ~uint32 | ~uint64 | ~uintptr
}

Jump to

Keyboard shortcuts

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