From 2674645475ff5b768d6d01f585dda26a70a1385c Mon Sep 17 00:00:00 2001 From: Ryan Cavicchioni Date: Thu, 4 Aug 2022 11:14:35 -0500 Subject: [PATCH] SeedMathRand should return an error --- lib/rand.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/rand.go b/lib/rand.go index d9e29fd..0a7f067 100644 --- a/lib/rand.go +++ b/lib/rand.go @@ -15,7 +15,7 @@ var ( ) // SeedMathRand Credit: https://github.com/hashicorp/consul/blob/main/lib/rand.go -func SeedMathRand() { +func SeedMathRand() error { var ( n *big.Int err error @@ -25,10 +25,11 @@ func SeedMathRand() { n, err = crand.Int(crand.Reader, big.NewInt(math.MaxInt64)) if err != nil { log.Errorf("cannot seed math/rand: %s", err) + } else { + log.Debugf("seeding math/rand %+v", n.Int64()) + rand.Seed(n.Int64()) } - - log.Debugf("seeding math/rand %+v", n.Int64()) - - rand.Seed(n.Int64()) }) + + return err }