random

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Boolean = Bool
View Source
var Char = Character
View Source
var CharacterPool = map[string][]rune{
	"lower":     []rune("abcdefghijklmnopqrstuvwxyz"),
	"upper":     []rune("ABCDEFGHIJKLMNOPQRSTUVWXYZ"),
	"letter":    []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),
	"number":    []rune("0123456789"),
	"symbol":    []rune("!@#$%^&*()[]"),
	"numletter": []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"),
	"any":       []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()[]"),

	"alpha": []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),
	"":      []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()[]"),
}
View Source
var Float = Float64
View Source
var Int = Integer
View Source
var MaxInt = 9007199254740992
View Source
var MinInt = -9007199254740992
View Source
var Sentences []string
View Source
var Str = String

Functions

func Bool

func Bool() bool

func Character

func Character(pool string) rune

利用 pool 生成随机一个随机字符

func CharacterR

func CharacterR(pool []rune) rune

利用 pool 生成随机一个随机字节 与 Character 的区别:不会进行 pool 映射

func Float32

func Float32(min, max float32) float32

func Float64

func Float64(min, max float64) float64

func Increment

func Increment() int64

func IncrementN

func IncrementN(ns string) int64

func IncrementNReset

func IncrementNReset(ns string)

func IncrementNWithDelta

func IncrementNWithDelta(ns string, delta int64) int64

func IncrementNWithStep

func IncrementNWithStep(ns string, step int64) int64

func IncrementNWithStepAndDelta

func IncrementNWithStepAndDelta(ns string, step, delta int64) int64

func IncrementReset

func IncrementReset()

func IncrementWithDelta

func IncrementWithDelta(delta int64) int64

func IncrementWithStep

func IncrementWithStep(step int64) int64

func IncrementWithStepAndDelta

func IncrementWithStepAndDelta(step, delta int64) int64

func Integer

func Integer(min, max int) int

返回一个随机的整数 - min 最小值 - max 最大值

映射情况 1: min > max -> swap(min, max)

func MapCharacterPool

func MapCharacterPool(pool string) []rune

pool 映射

func MustRegister

func MustRegister(MustRegisterFunction func(params ...interface{}))

func Natural

func Natural(min, max int) int

返回一个在 [min, max] 之间的随机自然数(大于等于 0 的整数) - min 最小值 - max 最大值

func SelectInts added in v1.1.0

func SelectInts(slice []int, count int) []int

func Sentence

func Sentence() string

func String

func String(pool string, min, max int) string

生成随机字符串 pool - 池 min - 最小生成数量 max - 最大生成数量

func Unique added in v1.1.0

func Unique(min, max, count int) []int

从 [min, max) 区间范围内随机返回 count 数量的不同的数字,按照升序排列

Types

This section is empty.

Jump to

Keyboard shortcuts

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