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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user