From fd4dbd4f01e0cd3421bef1aa038a8e97781e381d Mon Sep 17 00:00:00 2001 From: efron Date: Thu, 27 Jun 2024 14:58:56 -0700 Subject: [PATCH] feat: update math/rand to math/rand/v2 --- cmd/croc/send.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/cmd/croc/send.go b/cmd/croc/send.go index 32a4424..14ed219 100644 --- a/cmd/croc/send.go +++ b/cmd/croc/send.go @@ -2,10 +2,9 @@ package croc import ( "fmt" - "math/rand" + "math/rand/v2" "strconv" "strings" - "time" "github.com/schollz/croc/v9/src/models" "github.com/schollz/croc/v9/src/utils" @@ -32,9 +31,6 @@ var SendCmd = &cobra.Command{ Short: "send file(s), or folder", Long: "send file(s), or folder to pod or any computer", Run: func(cmd *cobra.Command, args []string) { - - rand.Seed(time.Now().UnixNano()) - // Make a GET request to the URL relays, err := GetRelays() if err != nil { @@ -43,9 +39,9 @@ var SendCmd = &cobra.Command{ return } + randIndex := rand.IntN(len(relays)) // Choose a random relay from the array - randomIndex := rand.Intn(len(relays)) - relay := relays[randomIndex] + relay := relays[randIndex] crocOptions := Options{ Curve: "p256", @@ -78,7 +74,7 @@ var SendCmd = &cobra.Command{ crocOptions.SharedSecret = utils.GetRandomName() } - crocOptions.SharedSecret = crocOptions.SharedSecret + "-" + strconv.Itoa(randomIndex) + crocOptions.SharedSecret = crocOptions.SharedSecret + "-" + strconv.Itoa(randIndex) minimalFileInfos, emptyFoldersToTransfer, totalNumberFolders, err := GetFilesInfo(fnames, crocOptions.ZipFolder) if err != nil {