rand

package
v0.0.0-...-d62a2a9 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func B

func B(n int) []byte

B retrieves and returns random bytes of given length `n`.

func D

func D(min, max time.Duration) time.Duration

D returns a random time.Duration between min and max: [min, max].

func Digits

func Digits(n int) string

Digits returns a random string which contains only digits, and its length is `n`.

func GenerateRuleName

func GenerateRuleName() string

func GenerateUUID20

func GenerateUUID20() string

GenerateUUID20 @description: 20位uuid @param: @author: GJing @email: gjing1st@gmail.com @date: 2022/4/6 11:39 @success:

func GenerateUUID32

func GenerateUUID32() string

GenerateUUID32 @description: 生成uid 32位 @param: @author: GJing @email: gjing1st@gmail.com @date: 2022/4/6 11:37 @success:

func GooGleUUID

func GooGleUUID() string

func GoogleUUID20

func GoogleUUID20() string

GoogleUUID20 @description: 20位uuid @param: @author: GJing @email: gjing1st@gmail.com @date: 2022/4/6 13:11 @success:

func GoogleUUID32

func GoogleUUID32() string

GoogleUUID32 @description: google/uuid @param: @author: GJing @email: gjing1st@gmail.com @date: 2022/4/6 13:08 @success:

func Intn

func Intn(max int) int

Intn returns a int number which is between 0 and max: [0, max).

Note that: 1. The `max` can only be greater than 0, or else it returns `max` directly; 2. The result is greater than or equal to 0, but less than `max`; 3. The result number is 32bit and less than math.MaxUint32.

func LS

func LS(n int) string

LS 返回小写字母

func Letters

func Letters(n int) string

Letters returns a random string which contains only letters, and its length is `n`.

func Meet

func Meet(num, total int) bool

Meet randomly calculate whether the given probability `num`/`total` is met.

func MeetProb

func MeetProb(prob float32) bool

MeetProb randomly calculate whether the given probability is met.

func N

func N(min, max int) int

N returns a random int between min and max: [min, max]. The `min` and `max` also support negative numbers.

func Perm

func Perm(n int) []int

Perm returns, as a slice of n int numbers, a pseudo-random permutation of the integers [0,n). TODO performance improving for large slice producing.

func S

func S(n int, symbols ...bool) string

S returns a random string which contains digits and letters, and its length is `n`. The optional parameter `symbols` specifies whether the result could contain symbols, which is false in default.

func Str

func Str(s string, n int) string

Str randomly picks and returns `n` count of chars from given string `s`. It also supports unicode string like Chinese/Russian/Japanese, etc.

func Symbols

func Symbols(n int) string

Symbols returns a random string which contains only symbols, and its length is `n`.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL