all: migrate from math/rand to math/rand/v2#270
Merged
Conversation
Migrate the random number generation from math/rand to math/rand/v2 across all three modules (main, flow, cmd). The v2 package uses the ChaCha8 generator which provides improved performance and better scalability. It also removes the need for manual seeding, so the init() call in rand.go is no longer needed. API changes applied: - rand.Intn -> rand.IntN - rand.Int63n -> rand.Int64N - rand.Read -> crypto/rand.Read (removed from v2) - rand.Seed -> deleted (v2 auto-seeds) The staticcheck SA1019 lint suppressions for the deprecated rand.Read and rand.Seed calls are also removed, as noted by the existing TODO comment in .golangci.yml. Fixes: cilium#263 Signed-off-by: Istvan Csaba Varga <istvan.csaba.varga@accenture.com>
kaworu
requested changes
Mar 24, 2026
Member
kaworu
left a comment
There was a problem hiding this comment.
Hi @IstvanCsVarga 👋 and thank you for the PR!
I'm blocking it momentarily because I wish to coordinate this change with #271, i.e. discuss which one we should merge first, because they will definitely be conflicting. The patch itself LGTM.
rolinh
approved these changes
Mar 24, 2026
Member
rolinh
left a comment
There was a problem hiding this comment.
LGTM, thanks for your contribution!
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #263
Migrate the random number generation from math/rand to math/rand/v2 across all three modules (main, flow, cmd).
The v2 package uses the ChaCha8 generator which provides improved performance and better scalability. It also removes the need for manual seeding, so the init() call in rand.go is deleted.
API changes applied:
The staticcheck SA1019 lint suppressions for the deprecated rand.Read and rand.Seed calls are also removed, as noted by the existing TODO comment in .golangci.yml.
All three modules tests pass locally.