Documentation ¶
Index ¶
- func Bool() bool
- func ChineseName() string
- func Duration(min time.Duration, max time.Duration) time.Duration
- func EnglishName() string
- func Float[F constraints.Float](min, max F) F
- func FloatN[F constraints.Float](n F) F
- func HostName() string
- func IPv4Address() string
- func IPv4Host() string
- func IPv6Address() string
- func IPv6Host() string
- func Int[I constraints.Int](min, max I) I
- func IntN[I constraints.Int](n I) I
- func MAC() string
- func NumberVerificationCode(length 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 UsablePort() int
- func VerificationCode(length int) string
- 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)
- type NameGenerator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChineseName ¶
func ChineseName() string
func EnglishName ¶
func EnglishName() string
func NumberVerificationCode ¶
NumberVerificationCode 返回一个随机产生的数字验证码
func ProbabilityChooseOne ¶
ProbabilityChooseOne 输入一组概率,返回命中的索引
func ProbabilitySlice ¶
func ProbabilitySlice[T any](getProbabilityHandle func(data T) float64, data ...T) (hit T, miss bool)
ProbabilitySlice 按概率随机从切片中产生一个数据并返回命中的对象及是否未命中
- 当总概率小于 1 将会发生未命中的情况
func ProbabilitySliceIndex ¶
func ProbabilitySliceIndex[T any](getProbabilityHandle func(data T) float64, data ...T) (hit T, index int, miss bool)
ProbabilitySliceIndex 按概率随机从切片中产生一个数据并返回命中的对象及对象索引以及是否未命中
- 当总概率小于 1 将会发生未命中的情况
func WeightMap ¶
func WeightMap[K comparable, T any](getWeightHandle func(data T) int64, data map[K]T) T
WeightMap 按权重随机从map中产生一个数据并返回
func WeightMapKey ¶
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 ¶
WeightSliceIndex 按权重随机从切片中产生一个数据并返回数据和对应索引
Types ¶
type NameGenerator ¶
type NameGenerator struct {
// contains filtered or unexported fields
}
NameGenerator 姓名生成器
func DefaultChineseNameGenerator ¶
func DefaultChineseNameGenerator() *NameGenerator
DefaultChineseNameGenerator 返回一个默认的中文姓名生成器
func DefaultEnglishNameGenerator ¶
func DefaultEnglishNameGenerator() *NameGenerator
DefaultEnglishNameGenerator 返回一个默认的英文姓名生成器
func (*NameGenerator) AddFirstNames ¶
func (n *NameGenerator) AddFirstNames(firstNames ...string)
func (*NameGenerator) AddLastNames ¶
func (n *NameGenerator) AddLastNames(lastNames ...string)
func (*NameGenerator) RandomName ¶
func (n *NameGenerator) RandomName() string
func (*NameGenerator) SetFirstNameCount ¶
func (n *NameGenerator) SetFirstNameCount(count int)
Click to show internal directories.
Click to hide internal directories.