(minor) fix invalid random seed

This commit is contained in:
Lawrence, Rendall
2022-06-23 21:37:17 +03:00
parent 0fd0e06360
commit 4a16fc62a0
+3 -3
View File
@@ -15,12 +15,12 @@ func init() {
// GenSeed returns 64bit seed from crypto/rand source or
// from current time, if crypto random error occurred
func GenSeed() (seed int64) {
r := make([]byte, 0, 8)
r := make([]byte, 8)
if _, err := cr.Read(r); err == nil {
seed = time.Now().UnixNano()
} else {
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
}