tailscale.comtailscale.com/util/rands Index | Files

package rands

import "tailscale.com/util/rands"

Package rands contains utility functions for randomness.

Index

Functions

func HexString

func HexString(n int) string

HexString returns a string of n cryptographically random lowercase hex characters.

That is, HexString(3) returns something like "0fc", containing 12 bits of randomness.

func IntN

func IntN(seed uint64, n int) int

IntN is like rand.IntN, but it is seeded on the stack and does not allocate or lock any RNG state.

func Perm

func Perm(seed uint64, n int) []int

Perm is like rand.Perm, but it is seeded on the stack and does not allocate or lock any RNG state.

func Shuffle

func Shuffle[T any](seed uint64, data []T)

Shuffle is like rand.Shuffle, but it does not allocate or lock any RNG state.

Source Files

cheap.go rands.go

Version
v1.84.0 (latest)
Published
May 21, 2025
Platform
linux/amd64
Imports
4 packages
Last checked
2 days ago

Tools for package owners.