remove randseed package

This commit is contained in:
Lawrence, Rendall
2023-03-19 20:13:44 +03:00
parent 34c2921be8
commit 63e0b93db4
8 changed files with 12 additions and 42 deletions

View File

@@ -1,27 +0,0 @@
// Package randseed just seeds (math) rand.Rand
package randseed
import (
cr "crypto/rand"
"math/rand"
"time"
)
func init() {
// Seeding global math random
//nolint:staticcheck
rand.Seed(GenSeed())
}
// GenSeed returns 64bit seed from crypto/rand source or
// from current time, if crypto random read error occurred
func GenSeed() (seed int64) {
r := make([]byte, 8)
if _, err := cr.Read(r); err == nil {
seed = int64(r[0])<<56 | int64(r[1])<<48 | int64(r[2])<<40 | int64(r[3])<<32 |
int64(r[4])<<24 | int64(r[5])<<16 | int64(r[6])<<8 | int64(r[7])
} else {
seed = time.Now().UnixNano()
}
return
}