mirror of
https://github.com/jefferyjob/go-easy-utils.git
synced 2025-10-05 15:06:50 +08:00
13 lines
204 B
Go
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))
|
|
}
|