mirror of https://github.com/milvus-io/milvus.git
Fix bug: rand.Seed reset and generate duplicate number (#5361)
Signed-off-by: zhenshan.cao <zhenshan.cao@zilliz.com>pull/5358/head^2
parent
457e964e41
commit
4e1b12269b
|
@ -16,8 +16,10 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
var Rand *rand.Rand = nil
|
||||
|
||||
func init() {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
Rand = rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
}
|
||||
|
||||
var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
||||
|
@ -25,7 +27,7 @@ var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
|||
func RandomString(n int) string {
|
||||
b := make([]rune, n)
|
||||
for i := range b {
|
||||
b[i] = letterRunes[rand.Intn(len(letterRunes))]
|
||||
b[i] = letterRunes[Rand.Intn(len(letterRunes))]
|
||||
}
|
||||
return string(b)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue