Skip to content

Commit

Permalink
fix: deprecated rand.seed
Browse files Browse the repository at this point in the history
  • Loading branch information
jm33-m0 committed Dec 17, 2024
1 parent a6d191d commit 1515072
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions core/lib/util/str.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package util

import (
crypto_rand "crypto/rand"
"encoding/binary"
"encoding/csv"
"fmt"
"log"
Expand Down Expand Up @@ -105,14 +104,12 @@ func RandInt(min, max int) int {
log.Println("falling back to math/rand with time seed")
return rand.New(rand.NewSource(time.Now().UnixNano())).Intn(max-min) + min
}
rand.Seed(int64(binary.LittleEndian.Uint64(b[:])))
return min + rand.Intn(max-min)
}

// RandStr random string
func RandStr(n int) string {
letters := []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
rand.Seed(int64(RandInt(0xff, math.MaxInt)))
b := make([]rune, n)
for i := range b {
b[i] = letters[int64(RandInt(0, len(letters)))]
Expand Down

0 comments on commit 1515072

Please sign in to comment.