print
CI / changes (push) Successful in 1m30s
CI / ad (push) Successful in 31s
CI / admin (push) Successful in 22s
CI / bff (push) Successful in 20s
CI / chore (push) Successful in 21s
CI / equipment (push) Successful in 22s
CI / express (push) Successful in 21s
CI / factory (push) Successful in 19s
CI / message (push) Successful in 18s
CI / order (push) Successful in 19s
CI / payment (push) Successful in 20s
CI / percutaneous (push) Successful in 19s
CI / product (push) Successful in 20s
CI / record (push) Successful in 19s
CI / sale (push) Successful in 19s
CI / support (push) Successful in 19s
CI / task (push) Successful in 18s
CI / user (push) Successful in 19s
CI / wecom (push) Successful in 20s

This commit is contained in:
2026-10-09 17:57:16 +08:00
parent 9226644073
commit f5749b87dc
11 changed files with 714 additions and 81 deletions
+13
View File
@@ -597,6 +597,19 @@ func UniqueStr(arr []string) []string {
return res
}
func initRandGenerator() {
// 创建随机数源
source := rand.NewSource(time.Now().UnixNano())
// 基于源创建生成器
randGen = rand.New(source)
}
func GetRandNum(number int) int {
// 首次调用时初始化,后续调用直接复用,无重复初始化开销
once.Do(initRandGenerator)
// 生成0-9999随机数,格式化补零为4位
return randGen.Intn(number)
}
// Float 泛型约束,只允许 float32 / float64
type Float interface {
~float32 | ~float64