From f96f6afa7f4f2b55f6f846749733610cc79c28b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?To=CF=80?= Date: Thu, 10 Aug 2023 01:21:27 +0200 Subject: [PATCH] don't use deprecated rand.Seed --- internal/insecurerandstr/random_str.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/insecurerandstr/random_str.go b/internal/insecurerandstr/random_str.go index 360a9ec17..3f5698a27 100644 --- a/internal/insecurerandstr/random_str.go +++ b/internal/insecurerandstr/random_str.go @@ -6,17 +6,17 @@ import ( "time" ) -var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") +var ( + letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") -func init() { - rand.Seed(time.Now().UnixNano()) -} + randStr = rand.New(rand.NewSource(time.Now().UnixNano())) +) // RandStr returns a random string of the given length. func RandStr(n int) string { b := make([]rune, n) for i := range b { - b[i] = letters[rand.Intn(len(letters))] + b[i] = letters[randStr.Intn(len(letters))] } return string(b) }