Current uses of `makeRandomString` is to create really
long strings. In #10794, I used them to create nearly-unique
unix paths for the daemon. Although collions are harmless and
don't fail the tests, this prevents the same strings from being
created consistently in every run by seeding rand.Random.
Signed-off-by: Ahmet Alp Balkan <ahmetalpbalkan@gmail.com>
... | ... |
@@ -235,8 +235,9 @@ func makeRandomString(n int) string { |
235 | 235 |
// make a really long string |
236 | 236 |
letters := []byte("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") |
237 | 237 |
b := make([]byte, n) |
238 |
+ r := rand.New(rand.NewSource(time.Now().UTC().UnixNano())) |
|
238 | 239 |
for i := range b { |
239 |
- b[i] = letters[rand.Intn(len(letters))] |
|
240 |
+ b[i] = letters[r.Intn(len(letters))] |
|
240 | 241 |
} |
241 | 242 |
return string(b) |
242 | 243 |
} |