mirror of
https://github.com/HDT3213/godis.git
synced 2025-10-06 09:17:10 +08:00
add unittests and bug fix
This commit is contained in:
13
lib/utils/rand_string.go
Normal file
13
lib/utils/rand_string.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package utils
|
||||
|
||||
import "math/rand"
|
||||
|
||||
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
|
||||
|
||||
func RandString(n int) string {
|
||||
b := make([]rune, n)
|
||||
for i := range b {
|
||||
b[i] = letters[rand.Intn(len(letters))]
|
||||
}
|
||||
return string(b)
|
||||
}
|
Reference in New Issue
Block a user