random

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2026 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Overview

Package random provides some random functions.

Index

Constants

View Source
const (
	NumCharset      = "0123456789"
	HexCharset      = NumCharset + "abcdefABCDEF"
	HexLowerCharset = NumCharset + "abcdef"
	HexUpperCharset = NumCharset + "ABCDEF"

	AlphaLowerCharset = "abcdefghijklmnopqrstuvwxyz"
	AlphaUpperCharset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	AlphaCharset      = AlphaLowerCharset + AlphaUpperCharset

	AlphaNumLowerCharset = NumCharset + AlphaLowerCharset
	AlphaNumUpperCharset = NumCharset + AlphaUpperCharset
	AlphaNumCharset      = NumCharset + AlphaCharset
)

Pre-define some charsets to generate the random string.

Variables

View Source
var DefaultCharset = AlphaNumLowerCharset

DefaultCharset is the default charset.

Functions

func Bytes

func Bytes(buf []byte, charset string)

Bytes generates a random string with the length from the given charsets into buf.

func Int64N

func Int64N(n int64) int64

Int64N returns a random integer in [0, n) as int64.

func IntN

func IntN(n int) int

IntN returns a random integer in [0, n) as int.

func Seed

func Seed() int64

Seed returns a random 64-bit signed integer seed.

func SeedString

func SeedString() string

SeedString returns a random 64-bit signed integer string.

func String

func String(n int, charset string) string

String generates a random string with the length from the given charsets.

Types

This section is empty.

Jump to

Keyboard shortcuts

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