Documentation ¶
Overview ¶
Package krand is a library for generating random strings, integers, floating point numbers.
Index ¶
Constants ¶
const ( R_NUM = 1 // only number R_UPPER = 2 // only capital letters R_LOWER = 4 // only lowercase letters R_All = 7 // numbers, upper and lower case letters )
nolint
Variables ¶
This section is empty.
Functions ¶
func Bytes ¶
Bytes generate random strings of any length of multiple types, default length is 6 if bytesLen is empty example: Bytes(R_ALL), Bytes(R_ALL, 16), Bytes(R_NUM|R_LOWER, 16)
func Float64 ¶
Float64 generates a random floating point number of the specified range size, Four types of passing references are supported, example: Float64(dpLength), Float64(dpLength, max), Float64(dpLength, min, max), Float64(dpLength, max, min), min<=random numbers<=max
func Int ¶
Int generate random numbers of specified range size, compatible with Int(), Int(max), Int(min, max), Int(max, min) 4 ways, min<=random number<=max
func NewSeriesID ¶ added in v1.10.0
func NewSeriesID() string
NewSeriesID Generate a datetime+random string ID, datetime is microsecond precision, 20 bytes, random is 6 bytes, total 26 bytes. example: 20060102150405000000123456
func NewStringID ¶ added in v1.10.0
func NewStringID() string
NewStringID Generate a string ID, the hexadecimal form of NewID(), total 16 bytes.
Types ¶
This section is empty.