From 7c282b8c11302c13469fbc24eb0e6b847a9dd458 Mon Sep 17 00:00:00 2001 From: eriknordmark Date: Wed, 7 Feb 2024 11:42:03 +0100 Subject: [PATCH] yetus: Remove calls to rand.Seed() Fixes: golangcilint: SA1019: rand.Seed has been deprecated since Go 1.20 and an alternative has been available since Go 1.0: As of Go 1.20 there is no reason to call Seed with a random value. Programs that call Seed with a known value to get a specific sequence of results should use New(NewSource(seed)) to obtain a local random generator. (staticcheck) Signed-off-by: eriknordmark --- pkg/pillar/execlib/execlib.go | 7 +------ pkg/pillar/tgt/tgt.go | 4 ---- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/pkg/pillar/execlib/execlib.go b/pkg/pillar/execlib/execlib.go index 6dd21e2628..6d9425b2a5 100644 --- a/pkg/pillar/execlib/execlib.go +++ b/pkg/pillar/execlib/execlib.go @@ -49,12 +49,7 @@ func New(ps *pubsub.PubSub, log *base.LogObject, agentName string, executor stri }) pubExecConfig.Unpublish(agentName) - // Start with a random number in case the process as run before - // and used some sequence - now := time.Now() - _, _, seed := now.Clock() - seed += now.Nanosecond() - rand.Seed(int64(seed)) + // No need to use rand.Seed() any more sequence := rand.Int() handle := ExecuteHandle{ diff --git a/pkg/pillar/tgt/tgt.go b/pkg/pillar/tgt/tgt.go index b0a2a96eb8..c5e498c29d 100644 --- a/pkg/pillar/tgt/tgt.go +++ b/pkg/pillar/tgt/tgt.go @@ -22,10 +22,6 @@ const ( naaPrefix = "5001405" // from rtslib-fb ) -func init() { - rand.Seed(time.Now().UnixNano()) -} - func waitForFile(fileName string) error { maxDelay := time.Second * 5 delay := time.Millisecond * 500