refactor: use math/rand only for seed command initialization
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
package commands
|
package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
cryptoRand "crypto/rand"
|
|
||||||
"errors"
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -26,11 +25,6 @@ var (
|
|||||||
func initSeedRand() {
|
func initSeedRand() {
|
||||||
seedRandOnce.Do(func() {
|
seedRandOnce.Do(func() {
|
||||||
seed := time.Now().UnixNano()
|
seed := time.Now().UnixNano()
|
||||||
seedBytes := make([]byte, 8)
|
|
||||||
if _, err := cryptoRand.Read(seedBytes); err == nil {
|
|
||||||
seed = int64(seedBytes[0])<<56 | int64(seedBytes[1])<<48 | int64(seedBytes[2])<<40 | int64(seedBytes[3])<<32 |
|
|
||||||
int64(seedBytes[4])<<24 | int64(seedBytes[5])<<16 | int64(seedBytes[6])<<8 | int64(seedBytes[7])
|
|
||||||
}
|
|
||||||
seedRandSource = rand.New(rand.NewSource(seed))
|
seedRandSource = rand.New(rand.NewSource(seed))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user