Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change randomness behaviour to be like it was prior to go1.20 #16

Conversation

Bios-Marcel
Copy link

Pre go1.20, rand.Seed needed to be called for randomness. Meaning, that math/rand delivered deterministic values by default. This was changed however. To restore the old behaviour, we need to manually seed our random generator with a constant.

Additionally, this introduce a local instance of rand.Rand, in order to prevent unexpected behaviour with other code that relies on the global math/rand package.

Fixes #10 (The readme and docs explain this, therefore I consider this solved, as it is by design and not a bug)

Fixes #15

Pre go1.20, rand.Seed needed to be called for randomness. Meaning, that
math/rand delivered deterministic values by default. This was changed
however. To restore the old behaviour, we need to manually seed our
random generator with a constant.

Additionally, this introduce a local instance of rand.Rand, in order
to prevent unexpected behaviour with other code that relies on the
global math/rand package.

Fixes dustinkirkland#10 (The readme and docs explain this, therefore I consider this
solved, as it is by design and not a bug)

Fixes dustinkirkland#15
@Bios-Marcel Bios-Marcel force-pushed the bugfix/go1.20_restore_previous_behaviour branch from 595be26 to 64ecdb6 Compare August 26, 2023 12:42
@Bios-Marcel Bios-Marcel changed the title Change randomness behaviour to be like it prior to go1.20 Change randomness behaviour to be like it was prior to go1.20 Aug 26, 2023
@Bios-Marcel
Copy link
Author

Closing this, since this is seemingly deemed unimportant 🤷

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.

Randomness behaviour with go 1.20 Petname generation is not "random" unless rand.Seed is set
1 participant