Documentation ¶
Index ¶
- func Bool() bool
- func ChineseName() string
- func Dice() int
- func DiceN(n int) int
- func Duration(min int64, max int64) time.Duration
- func EnglishName() string
- func Float32() float32
- func Float32Range(min float32, max float32) float32
- func Float64() float64
- func Float64Range(min float64, max float64) float64
- func HostName() string
- func IPv4() string
- func IPv4Port() string
- func Int(min int, max int) int
- func Int32(min int32, max int32) int32
- func Int64(min int64, max int64) int64
- func IntN(n int) int
- func Name() string
- func NetIP() net.IP
- func NumberString(min int, max int) string
- func NumberStringRepair(min int, max int) string
- func Port() int
- func Probability(p int, full ...int) bool
- func ProbabilityChooseOne(ps ...int) int
- func ProbabilitySlice[T any](getProbabilityHandle func(data T) float64, data ...T) (hit T, miss bool)
- func ProbabilitySliceIndex[T any](getProbabilityHandle func(data T) float64, data ...T) (hit T, index int, miss bool)
- func RefreshSeed(seed ...int64)
- func UsablePort() int
- func WeightMap[K comparable, T any](getWeightHandle func(data T) int64, data map[K]T) T
- func WeightMapKey[K comparable, T any](getWeightHandle func(data T) int64, data map[K]T) (item T, key K)
- func WeightSlice[T any](getWeightHandle func(data T) int64, data ...T) T
- func WeightSliceIndex[T any](getWeightHandle func(data T) int64, data ...T) (item T, index int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Float32Range ¶ added in v0.5.4
Float32Range 返回一个介于min和max之间的的float32类型的随机数。
func Float64Range ¶ added in v0.5.4
Float64Range 返回一个介于min和max之间的的float64类型的随机数。
func NumberString ¶
NumberString 返回一个介于min和max之间的string类型的随机数。
func NumberStringRepair ¶
NumberStringRepair 返回一个介于min和max之间的string类型的随机数
- 通过Int64生成一个随机数,当结果的字符串长度小于max的字符串长度的情况下,使用0在开头补齐。
func ProbabilityChooseOne ¶ added in v0.0.24
ProbabilityChooseOne 输入一组概率,返回命中的索引
func ProbabilitySlice ¶ added in v0.2.0
func ProbabilitySlice[T any](getProbabilityHandle func(data T) float64, data ...T) (hit T, miss bool)
ProbabilitySlice 按概率随机从切片中产生一个数据并返回命中的对象及是否未命中
- 当总概率小于 1 将会发生未命中的情况
func ProbabilitySliceIndex ¶ added in v0.2.1
func ProbabilitySliceIndex[T any](getProbabilityHandle func(data T) float64, data ...T) (hit T, index int, miss bool)
ProbabilitySliceIndex 按概率随机从切片中产生一个数据并返回命中的对象及对象索引以及是否未命中
- 当总概率小于 1 将会发生未命中的情况
func RefreshSeed ¶
func RefreshSeed(seed ...int64)
func WeightMap ¶
func WeightMap[K comparable, T any](getWeightHandle func(data T) int64, data map[K]T) T
WeightMap 按权重随机从map中产生一个数据并返回
func WeightMapKey ¶ added in v0.2.1
func WeightMapKey[K comparable, T any](getWeightHandle func(data T) int64, data map[K]T) (item T, key K)
WeightMapKey 按权重随机从map中产生一个数据并返回数据和对应 key
func WeightSlice ¶
WeightSlice 按权重随机从切片中产生一个数据并返回
func WeightSliceIndex ¶ added in v0.2.1
WeightSliceIndex 按权重随机从切片中产生一个数据并返回数据和对应索引
Types ¶
This section is empty.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.