Documentation ¶
Overview ¶
Package rand contains randomization functions for use in unit/regression/integration tests or anywhere where randomized data is needed.
Index ¶
- Constants
- func IPv4(startingIP uint32, mask uint32) uint32
- func IPv4Str(startingIP uint32, mask uint32) string
- func IntArrayUnique(n int) []int
- func MACAddr48() uint64
- func MACAddr48Str(sep string) string
- func MACAddr64() uint64
- func MACAddr64Str(sep string) string
- func String(n int, alphabet string) string
- func Time() time.Time
Constants ¶
const ( Lower = "abcdefghijklmnopqrstuvwxyz" Upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" Digit = "0123456789" Whitespace = "\t\r\n " Special = "`~!@#$%^&*()-_=+[]{}\\|:;'\"/?,.<>" )
Constants for commonly used alphabets to provide to String()
const ( // Class A network mask: 255.0.0.0 => /8 IPv4ClassAMask uint32 = 0xFF000000 // Class B network mask: 255.255.0.0 => /16 IPv4ClassBMask uint32 = 0xFFFF0000 // CLass C network mask: 255.255.255.0 => /24 IPv4ClassCMask uint32 = 0xFFFFFF00 // Private class B network mask: 255.240.0.0 => /12 IPv4PrivateClassBMask uint32 = 0xFFF00000 // Private Class C network mask: 255.255.0.0 => /16 IPv4PrivateClassCMask uint32 = 0xFFFF0000 )
IPv4 network mask constants
const ( // Class A IP address start: 1.0.0.0 IPv4ClassAStart uint32 = 0x01000000 // Class B IP address start: 128.0.0.0 IPv4ClassBStart uint32 = 0x80000000 // Class C IP address start: 192.0.0.0 IPv4ClassCStart uint32 = 0xC0000000 // Class D IP address start: 224.0.0.0 IPv4ClassDStart uint32 = 0xE0000000 // Class E IP address start: 240.0.0.0 IPv4ClassEStart uint32 = 0xF0000000 // Class A private IP address start: 10.0.0.0 IPv4PrivateClassAStart uint32 = 0x0A000000 // Class B private IP address start: 172.16.0.0 IPv4PrivateClassBStart uint32 = 0xAC100000 // Class C private IP address start: 192.168.0.0 IPv4PrivateClassCStart uint32 = 0xC0A80000 )
IPv4 network host starting address constants
Variables ¶
This section is empty.
Functions ¶
func IPv4 ¶
IPv4 generates a random IPv4 address beginning with the starting IP address and going up to the broadcast address for that network (inclusive). The ending IP address is determined based on the network mask.
func IPv4Str ¶
IPv4 generates a random IPv4 address and returns the IP address as a string in dotted quad notation. Inputs function similarly to IPv4().
func IntArrayUnique ¶
IntArrayUnique creates an array of size n filled with randomly generated integers. Each entry in the array will be unique. It panics if the length is negative.
func MACAddr48Str ¶
MACAddr48Str generates a random 48 bit MAC address as a string, using the desired separator between octets.
func MACAddr64Str ¶
MACAddr64Str generates a random 64 bit MAC address as a string, using the desired separator between octets.
Types ¶
This section is empty.