1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-08 22:52:29 +08:00

单独剥离出来一个为windows的,增加RandNumLen为取指定长度随机数.

This commit is contained in:
guanren
2024-10-18 13:23:04 +08:00
parent 1ecb016969
commit fc5ca5e39e
6 changed files with 131 additions and 38 deletions

View File

@@ -327,3 +327,11 @@ func UUIdV4() (string, error) {
return fmt.Sprintf("%x-%x-%x-%x-%x", uuid[0:4], uuid[4:6], uuid[6:8], uuid[8:10], uuid[10:]), nil
}
// RandNumLen 生成一个长度为len的随机数
func RandNumLen(len int) int {
m := int(math.Pow10(len) - 1)
i := int(math.Pow10(len - 1))
ret := rand.Intn(m-i+1) + i
return ret
}