avoid concurrenct use of rand.NewSource (#10543)

This commit is contained in:
Harshavardhana
2020-09-22 15:34:27 -07:00
committed by GitHub
parent 4c54ed8748
commit 0537a21b79
3 changed files with 5 additions and 7 deletions

View File

@@ -30,11 +30,11 @@ import (
humanize "github.com/dustin/go-humanize"
)
var randSrc = rand.New(rand.NewSource(time.Now().UnixNano()))
const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
func newRandString(length int) string {
randSrc := rand.New(rand.NewSource(time.Now().UnixNano()))
b := make([]byte, length)
for i := range b {
b[i] = charset[randSrc.Intn(len(charset))]