Skip to content

Commit 3ec67cf

Browse files
committed
cmd/start: Do not use deprecated rand.Seed
As per the method description: ```sh If Seed is not called, the generator is seeded randomly at program startup. ``` As noticed by a golangci-lint run: ```sh cmd/start.go:26:4: 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) rand.Seed(time.Now().UnixNano()) ^ ```
1 parent 4ceef7d commit 3ec67cf

File tree

1 file changed

+0
-6
lines changed

1 file changed

+0
-6
lines changed

cmd/start.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ package main
22

33
import (
44
"context"
5-
"math/rand"
6-
"time"
7-
85
"github.com/spf13/cobra"
96
"k8s.io/klog/v2"
107

@@ -22,9 +19,6 @@ func init() {
2219
// To help debugging, immediately log version
2320
klog.Info(version.String)
2421

25-
//Setting seed for all the calls to rand methods in the code
26-
rand.Seed(time.Now().UnixNano())
27-
2822
if err := opts.Run(context.Background()); err != nil {
2923
klog.Fatalf("error: %v", err)
3024
}

0 commit comments

Comments
 (0)