We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2c434d4 commit e8bf6b5Copy full SHA for e8bf6b5
rand.go
@@ -5,9 +5,10 @@ import (
5
"time"
6
)
7
8
-func init() {
9
- rand.Seed(time.Now().UnixNano())
10
-}
+var (
+ source = rand.NewSource(time.Now().UnixNano())
+ random = rand.New(source)
11
+)
12
13
// standard characters used by uniuri
14
const letterBytes = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
@@ -16,7 +17,7 @@ const letterBytes = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456
16
17
func RandomString(n int) string {
18
b := make([]byte, n)
19
for i := range b {
- b[i] = letterBytes[rand.Intn(len(letterBytes))]
20
+ b[i] = letterBytes[random.Intn(len(letterBytes))]
21
}
22
return string(b)
23
0 commit comments