random

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package random provides utilities and functions for generating random data.

Index

Constants

View Source
const Digits = "0123456789"

Character sets that you can use when passing into RandomString

View Source
const LowerLetters = "abcdefghijklmnopqrstuvwxyz"
View Source
const SpecialChars = "<>[]{}()-_*%&/?\"'\\"
View Source
const UpperLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

Variables

Functions

func RandomString

func RandomString(strLength int, allowedChars string) (string, error)

RandomString generates a random string of length strLength, composing only of characters in allowedChars. Based on code here: http://stackoverflow.com/a/9543797/483528 For convenience, the random package exposes various character sets you can use for the allowedChars parameter. Here are a few examples:

// Only lower case chars + digits random.RandomString(6, random.Digits + random.LowerLetters)

// alphanumerics + special chars random.RandomString(6, random.Base62Chars + random.SpecialChars)

// Only alphanumerics (base62) random.RandomString(6, random.Base62Chars)

// Only abc random.RandomString(6, "abc")

Types

This section is empty.

Jump to

Keyboard shortcuts

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