Files
go-easy-utils/mathUtil/rand.go
jeffery f97913a2bc Feature/math util (#22)
Development supports the math package
2023-04-12 11:10:07 +08:00

13 lines
204 B
Go

package mathUtil
import (
"math/rand"
"time"
)
// Rand 生成随机整数
func Rand[T Numeric](min, max T) T {
rand.Seed(time.Now().UnixNano())
return T(rand.Intn(int(max)-int(min)+1) + int(min))
}