Documentation
¶
Overview ¶
Rand package have auxiliary function to generate random numbers and random strings. It's give you the choice of use the random and pseudo-random number generator of go or you can use it direct (not portable way).
Index ¶
- Constants
- Variables
- func Bytes(l int, dev string) ([]byte, error)
- func Chars(l uint64, chars []string, dev string) (string, error)
- func FileName(prefix, ext string, letters int) (string, error)
- func Int63n(n int64, dev string) (int64, error)
- func Int64Crypto(l int) (int64, error)
- func Int64Go(l int) (int64, error)
- func Int64R() (int64, error)
- func Int64U() (int64, error)
- func RandomPermutation(in, out LenAtSetter, dev string) error
- func String(chars int, dev string) (string, error)
- func StringCrypto(l int) (string, error)
- func StringGo(l int) (string, error)
- func StringR(l int) (string, error)
- func StringU(l int) (string, error)
- func Uuid() (string, error)
- func UuidByte() ([]byte, error)
- type LenAtSetter
- type StringPermutation
Constants ¶
const ErrInvalidLength = "invalid length"
Variables ¶
var Letters []string = []string{"a", "b", "c", "d", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "x", "w", "y", "z", "A", "B", "C", "D", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "X", "W", "Y", "Z"}
var LowerCase []string = Letters[:25]
var MaxInt64 = 1<<63 - 1
MaxInt64 = 1<<63 - 1 = 2^64 - 1
var Number []string = []string{"1", "2", "3", "4", "5", "6", "7", "8", "9", "0"}
var NumberLetters []string = []string{"1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "a", "b", "c", "d", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "x", "w", "y", "z", "A", "B", "C", "D", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "X", "W", "Y", "Z"}
var NumberLettersSimbols []string = []string{"1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "a", "b", "c", "d", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "x", "w", "y", "z", "A", "B", "C", "D", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "X", "W", "Y", "Z", "!", "@", "#", "$", "%", "&", "*", "_", "-", "+", "=", "|", "\\", "/", "?", ":", ";", "<", ">", ",", "."}
var UpperCase []string = Letters[25:]
Functions ¶
func Chars ¶
Chars generate a random string with selected characters. l is the number of characters. Where chars is array with selected characters and dev is the path to the random number device or dev is go for the go pseudo random number generator or go-crypto for the random number generator.
func Int63n ¶
Int63n returns, as an int64, a non-negative random number in [0,n). Where dev is the path to the random number device or dev is go for the go pseudo random number generator.
func Int64Crypto ¶
Int64Crypto generate a int64 using go crypto random number generator
func RandomPermutation ¶
func RandomPermutation(in, out LenAtSetter, dev string) error
RandomPermutation scramble the in array and put the result in the out array. in and outs arrays must implement the LenAtSetter interface. dev is the random number generator device or go for the go pseudo-random ou go-crypto for the go random number generator.
func String ¶
String generate a string of random characters. Where l is the number of characters and dev is the path to the random number device or dev is go for the go pseudo random number generator.
func StringCrypto ¶
StringCrypto is like String but uses go crypto random number generator. Where l is the number of characters.
func StringGo ¶
Stringgo is like String but uses go random number generator. Where l is the number of characters.
Types ¶
type LenAtSetter ¶
type StringPermutation ¶
type StringPermutation []string
StringPermutation is an adaptor for permutate a string slice.
func (StringPermutation) At ¶
func (s StringPermutation) At(i int) interface{}
func (StringPermutation) Len ¶
func (s StringPermutation) Len() int
func (StringPermutation) Set ¶
func (s StringPermutation) Set(i int, val interface{})