diff --git a/cmd/object-api-utils.go b/cmd/object-api-utils.go index 88893fa65..55543671e 100644 --- a/cmd/object-api-utils.go +++ b/cmd/object-api-utils.go @@ -354,12 +354,10 @@ func getHostsSlice(records []dns.SrvRecord) []string { return hosts } -var rng = rand.New(rand.NewSource(time.Now().UTC().UnixNano())) - // returns an online host (and corresponding port) from a slice of DNS records func getHostFromSrv(records []dns.SrvRecord) (host string) { hosts := getHostsSlice(records) - + rng := rand.New(rand.NewSource(time.Now().UTC().UnixNano())) var d net.Dialer var retry int for retry < len(hosts) { diff --git a/cmd/test-utils_test.go b/cmd/test-utils_test.go index c44bf2ac4..bc70f9f8f 100644 --- a/cmd/test-utils_test.go +++ b/cmd/test-utils_test.go @@ -1235,10 +1235,10 @@ func getTestWebRPCResponse(resp *httptest.ResponseRecorder, data interface{}) er return nil } -var src = rand.NewSource(UTCNow().UnixNano()) - // Function to generate random string for bucket/object names. func randString(n int) string { + src := rand.NewSource(UTCNow().UnixNano()) + b := make([]byte, n) // A rand.Int63() generates 63 random bits, enough for letterIdxMax letters! for i, cache, remain := n-1, src.Int63(), letterIdxMax; i >= 0; { diff --git a/pkg/s3select/select_benchmark_test.go b/pkg/s3select/select_benchmark_test.go index 7c2b0a81f..c3bdd338d 100644 --- a/pkg/s3select/select_benchmark_test.go +++ b/pkg/s3select/select_benchmark_test.go @@ -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))]