random

package
v0.6.14 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MPL-2.0 Imports: 3 Imported by: 11 modules, 17 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 random is a helper for generating random alphanumeric strings.

Index

Constants

This section is empty.

Variables

View Source
var (
	PossibleNumbers          = "0123456789"
	PossibleLowerCase        = "abcdefghijklmnopqrstuvwxyz"
	PossibleUpperCase        = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	PossibleSpecialCharacter = " !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"

	PossibleAlphaNum      = PossibleNumbers + PossibleLowerCase + PossibleUpperCase
	PossibleAlphaNumLower = PossibleNumbers + PossibleLowerCase
	PossibleAlphaNumUpper = PossibleNumbers + PossibleUpperCase
)

Functions

func AlphaNum

func AlphaNum(length int) string

AlphaNum returns a random alphanumeric string of the given length. The returned string can contain both uppercase and lowercase letters.

func AlphaNumLower

func AlphaNumLower(length int) string

AlphaNumLower returns a random alphanumeric string of the given length. The returned string can contain lowercase letters, but not uppercase.

func AlphaNumUpper

func AlphaNumUpper(length int) string

AlphaNumUpper returns a random alphanumeric string of the given length. The returned string can contain uppercase letters, but not lowercase.

func Numbers

func Numbers(length int) string

Numbers returns a random numeric string of the given length

func String

func String(chooseFrom string, length int) (randomString string)

String returns a random string of the given length, using only the component characters provided in the "chooseFrom" string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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