Documentation
¶
Overview ¶
Package gorand defines a set of utility methods to work with random data.
The main goal is to curate a collection of functions for random data generation in different formats to be used for different purposes.
It uses the "crypto/rand" package to provide the most secure random data, unless indicated otherwise where performance can be the main focus of the method.
Most implementations are really trivial and anybody could write the same on their own packages, but here we can centralize all of them and keep a unified way of retrieving random data.
Unified QA is another motivator to have and use this package.
Index ¶
- func GetAlphaNumString(n int) (string, error)
- func GetAlphaString(n int) (string, error)
- func GetBytes(n int) ([]byte, error)
- func GetHex(n int) (string, error)
- func GetNumString(n int) (string, error)
- func GetRandomChars(c string, n int) (string, error)
- func ID() (id [64]byte, err error)
- func MarshalUUID(uuid UUID) (s string, err error)
- type UUID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAlphaNumString ¶
GetAlphaNumString returns a fixed length (n int) string of random letters and numbers [a-z][A-Z][0-9]
func GetAlphaString ¶
GetAlphaString returns a fixed length (n int) string of random letters [a-z][A-Z]
func GetBytes ¶
GetBytes returns a fixed amount of random bytes. Specify the amount of bytes wanted by passing it on the n parameter. This function is the base for most of the methods on this package.
func GetHex ¶
GetHex returns a string representation of a (n) bytes random hexadecimal number. The length of the result string will be twice as long as the amount of bytes requested due to hex representation.
func GetNumString ¶
GetNumString returns a fixed length (n int) string of random numbers [0-9]
func GetRandomChars ¶
GetRandomChars returns a fixed length string (n int) of chars contained on a collection string provided (c string).