Skip to content

hooks/test: fix incorrect use of math/rand#1426

Merged
thaJeztah merged 1 commit into
sirupsen:masterfrom
dolmen:testing-fix-use-of-math-rand
Aug 4, 2025
Merged

hooks/test: fix incorrect use of math/rand#1426
thaJeztah merged 1 commit into
sirupsen:masterfrom
dolmen:testing-fix-use-of-math-rand

Conversation

@dolmen

@dolmen dolmen commented Mar 12, 2024

Copy link
Copy Markdown
Contributor

Fix incorrect uses of math/rand:

Fix incorrect uses of math/rand:
- do not call rand.Seed() in a test as it affects the global pseudo-random number
  generator and might affect other tests (or Logrus itself). Instead, use a local
  instance of a number generator
- seed with time.Now().UnixNano() instead of time.Now().Unix() for more
  randomness
- use "rand.Intn(100)" instead of "rand.Int() % 100"

@thaJeztah thaJeztah left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@thaJeztah thaJeztah merged commit 21bae50 into sirupsen:master Aug 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants