randomutil

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RandomBytes

func RandomBytes(length int) []byte

RandomBytes 生成指定长度的安全随机字节数组

func RandomEle

func RandomEle[T any](list []T) T

RandomEle 从切片中随机返回一个元素

func RandomEleSet

func RandomEleSet[T comparable](list []T, num int) []T

RandomEleSet 从切片中随机返回不重复的元素集,返回一个集合

func RandomInt

func RandomInt(min, max int64) int64

RandomInt 生成一个 [min, max) 范围内的安全随机整数

func RandomNumbers

func RandomNumbers(length int) string

RandomNumbers 生成指定长度的随机数字字符串

func RandomString

func RandomString(length int) string

RandomString 生成指定长度的随机字符串(包含数字和字母)

func WeightRandom

func WeightRandom(items []Weighted) interface{}

WeightRandom 权重随机生成器,根据权重随机获取对象

Types

type Weighted

type Weighted struct {
	Item   interface{}
	Weight int64
}

Weighted 权重随机生成器结构

Jump to

Keyboard shortcuts

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