Skip to content

chore: Remove deprecated rand.Seed() calls - #16824

Merged
guzalv merged 1 commit into
masterfrom
master-base/gualvare/remove-deprecated-rand-seed
Sep 16, 2025
Merged

guzalv merged 1 commit into
masterfrom
master-base/gualvare/remove-deprecated-rand-seed

Conversation

@guzalv

@guzalv guzalv commented Sep 15, 2025 •

Copy link
Copy Markdown
Contributor

Description

As of Go 1.20 rand.Seed() has been deprecated (see Go docs), and linters point it out (e.g. those run by the pre-commit hook):

Deprecated: 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.

This PR removes the Seed() calls with random values, and implements the recommended change where non-random seed values were used.

User-facing documentation

Testing and quality

  • the change is production ready: the change is GA, or otherwise the functionality is gated by a feature flag
  • CI results are inspected

Automated testing

  • added unit tests
  • added e2e tests
  • added regression tests
  • added compatibility tests
  • modified existing tests

How I validated my change

CI

@openshift-ci

openshift-ci Bot commented Sep 15, 2025

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@guzalv

guzalv commented Sep 15, 2025

Copy link
Copy Markdown
Contributor Author

/test all

@guzalv
guzalv force-pushed the master-base/gualvare/remove-deprecated-rand-seed branch from c8f341b to fe3fb9a Compare September 15, 2025 13:56
@guzalv guzalv changed the title remove-deprecated-rand-seed chore: Remove deprecated rand.Seed() calls Sep 15, 2025
@guzalv
guzalv force-pushed the master-base/gualvare/remove-deprecated-rand-seed branch from fe3fb9a to 11cc9d4 Compare September 15, 2025 14:01
@rhacs-bot

rhacs-bot commented Sep 15, 2025 •

Copy link
Copy Markdown
Contributor

Images are ready for the commit at 6d0c221.

To use with deploy scripts, first export MAIN_IMAGE_TAG=4.9.x-784-g6d0c22156a.

@guzalv
guzalv force-pushed the master-base/gualvare/remove-deprecated-rand-seed branch from 11cc9d4 to ba5d8de Compare September 16, 2025 07:38
@codecov

codecov Bot commented Sep 16, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 48.96%. Comparing base (960eb0b) to head (6d0c221).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #16824      +/-   ##
==========================================
- Coverage   48.97%   48.96%   -0.01%     
==========================================
  Files        2690     2690              
  Lines      201445   201445              
==========================================
- Hits        98650    98642       -8     
- Misses      95144    95150       +6     
- Partials     7651     7653       +2     
Flag Coverage Δ
go-unit-tests 48.96% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

See https://pkg.go.dev/math/rand@go1.25.1#Seed:

Deprecated: 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.
@guzalv
guzalv force-pushed the master-base/gualvare/remove-deprecated-rand-seed branch from ba5d8de to 6d0c221 Compare September 16, 2025 09:44
@guzalv
guzalv marked this pull request as ready for review September 16, 2025 09:45
@guzalv
guzalv requested review from a team as code owners September 16, 2025 09:45

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@vikin91 vikin91 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice cleanup!

@guzalv
guzalv enabled auto-merge (squash) September 16, 2025 10:48
@guzalv
guzalv merged commit a08b4df into master Sep 16, 2025
93 of 94 checks passed
@guzalv
guzalv deleted the master-base/gualvare/remove-deprecated-rand-seed branch September 16, 2025 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants