random

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2021 License: MIT Imports: 3 Imported by: 1

Documentation

Overview

Package random provides utilities and functions for generating random data.

Index

Constants

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

Character sets that you can use when passing into String

Variables

Base62Chars is set of Base64 charsets

Functions

func String

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

String 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.String(6, random.Digits + random.LowerLetters)

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

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

// Only abc random.String(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