gf: github.com/gogf/gf/g/util/grand Index | Files

package grand

import "github.com/gogf/gf/g/util/grand"

Package grand provides high performance random string generation functionality.

Index

Package Files

grand.go grand_intn.go

func Digits Uses

func Digits(n int) string

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

func Intn Uses

func Intn(max int) int

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

Note: 1. The result is greater than or equal to 0, but less than <max>; 2. The result number is 32bit and less than math.MaxUint32.

func Letters Uses

func Letters(n int) string

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

func Meet Uses

func Meet(num, total int) bool

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

func MeetProb Uses

func MeetProb(prob float32) bool

MeetProb randomly calculate whether the given probability is met.

func N Uses

func N(min, max int) int

N returns a random int between min and max - [min, max].

func Perm Uses

func Perm(n int) []int

Perm returns, as a slice of n ints, a pseudo-random permutation of the integers [0,n).

func Rand Uses

func Rand(min, max int) int

Deprecated. Alias of N.

func RandDigits Uses

func RandDigits(n int) string

Deprecated. Alias of Digits.

func RandLetters Uses

func RandLetters(n int) string

Deprecated. Alias of Letters.

func RandStr Uses

func RandStr(n int) string

Deprecated. Alias of Str.

func Str Uses

func Str(n int) string

Str returns a random string which contains digits and letters, and its length is <n>.

Package grand imports 3 packages (graph) and is imported by 9 packages. Updated 2019-06-20. Refresh now. Tools for package owners.