mirror of
https://github.com/sot-tech/mochi.git
synced 2026-04-26 07:30:00 -07:00
remove randseed package
This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user