random

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RandomChoice

func RandomChoice[T any](items []T) T

RandomChoice returns a random element from the slice

func RandomHex

func RandomHex(length int) string

RandomHex generates a random hex string of given length

func RandomInt

func RandomInt(minVal, maxVal int64) int64

RandomInt generates a random integer in [minVal, maxVal)

func RandomPassword

func RandomPassword(length int) string

RandomPassword generates a random password of given length

func RandomString

func RandomString(length int) string

RandomString generates a random alphanumeric string of given length

func RunRandom

func RunRandom(w io.Writer, opts RandomOptions) error

RunRandom generates random values

func Shuffle

func Shuffle[T any](items []T)

Shuffle randomly shuffles a slice in place

Types

type RandomOptions

type RandomOptions struct {
	Count   int    // -n: number of values to generate
	Length  int    // -l: length of random strings
	Min     int64  // --min: minimum value for numbers
	Max     int64  // --max: maximum value for numbers
	Type    string // -t: type (int, float, string, hex, alpha, alnum, bytes)
	Charset string // -c: custom character set
	Sep     string // -s: separator between values
	JSON    bool   // --json: output as JSON
}

RandomOptions configures the random command behavior

type RandomResult

type RandomResult struct {
	Type   string   `json:"type"`
	Values []string `json:"values"`
	Count  int      `json:"count"`
}

RandomResult represents random output for JSON

Jump to

Keyboard shortcuts

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