diff --git a/rand.go b/rand.go index 9cd5beb..72b014e 100644 --- a/rand.go +++ b/rand.go @@ -5,9 +5,10 @@ import ( "time" ) -func init() { - rand.Seed(time.Now().UnixNano()) -} +var ( + source = rand.NewSource(time.Now().UnixNano()) + random = rand.New(source) +) // standard characters used by uniuri const letterBytes = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" @@ -16,7 +17,7 @@ const letterBytes = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456 func RandomString(n int) string { b := make([]byte, n) for i := range b { - b[i] = letterBytes[rand.Intn(len(letterBytes))] + b[i] = letterBytes[random.Intn(len(letterBytes))] } return string(b) }