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

doc: update doc for RandNumberOfLength and GetExeOrDllVersion

This commit is contained in:
dudaodong
2024-10-18 16:38:39 +08:00
parent ed93aae970
commit 0a2cc9c928
10 changed files with 86 additions and 24 deletions

View File

@@ -328,11 +328,12 @@ 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的随机数
// Play: https://go.dev/play/p/jpIalcD5rMo
func RandNumLen(len int) int {
// RandNumberOfLength 生成一个长度为len的随机数
// Play: todo
func RandNumberOfLength(len int) int {
m := int(math.Pow10(len) - 1)
i := int(math.Pow10(len - 1))
ret := rand.Intn(m-i+1) + i
return ret
}

View File

@@ -362,9 +362,9 @@ func TestRandBoolSlice(t *testing.T) {
}
})
}
func TestRandNumLen(t *testing.T) {
func TestRandNumberOfLength(t *testing.T) {
t.Parallel()
randi := RandNumLen(6)
assert := internal.NewAssert(t, "TestRandNumLen")
randi := RandNumberOfLength(6)
assert := internal.NewAssert(t, "TestRandNumberOfLength")
assert.Equal(6, len(strconv.Itoa(randi)))
}