rand

package
v1.28.10 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 5 Imported by: 364 modules, 337 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package rand provides utilities for creating and working with random value generators.

Index

Constants

This section is empty.

Variables

View Source
var Reader io.Reader

Reader provides a random reader that can reset during testing.

Functions

func CryptoRandInt63n

func CryptoRandInt63n(max int64) (int64, error)

CryptoRandInt63n returns a random int64 between zero and value of max obtained from the crypto rand source.

func Int63n

func Int63n(reader io.Reader, max int64) (int64, error)

Int63n returns a int64 between zero and value of max, read from an io.Reader source.

Types

type UUID

type UUID struct {
	// contains filtered or unexported fields
}

UUID provides computing random UUID version 4 values from a random source reader.

func NewUUID

func NewUUID(r io.Reader) *UUID

NewUUID returns an initialized UUID value that can be used to retrieve random UUID version 4 values.

func (*UUID) GetBytes added in v1.9.0

func (r *UUID) GetBytes() (u []byte, err error)

GetBytes returns a byte slice containing a random UUID version 4 sourced from the random reader the UUID was created with. Returns an error if unable to compute the UUID.

func (*UUID) GetUUID

func (r *UUID) GetUUID() (string, error)

GetUUID returns a random UUID version 4 string representation sourced from the random reader the UUID was created with. Returns an error if unable to compute the UUID.

type UUIDIdempotencyToken

type UUIDIdempotencyToken struct {
	// contains filtered or unexported fields
}

UUIDIdempotencyToken provides a utility to get idempotency tokens in the UUID format.

func NewUUIDIdempotencyToken

func NewUUIDIdempotencyToken(r io.Reader) *UUIDIdempotencyToken

NewUUIDIdempotencyToken returns a idempotency token provider returning tokens in the UUID random format using the reader provided.

func (UUIDIdempotencyToken) GetIdempotencyToken

func (u UUIDIdempotencyToken) GetIdempotencyToken() (string, error)

GetIdempotencyToken returns a random UUID value for Idempotency token.

Jump to

Keyboard shortcuts

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