diff --git a/internal/util/funcutil/random.go b/internal/util/funcutil/random.go index ad3f5f8682..2159eaeb0f 100644 --- a/internal/util/funcutil/random.go +++ b/internal/util/funcutil/random.go @@ -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) }