-
Notifications
You must be signed in to change notification settings - Fork 38
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
Petname generation is not "random" unless rand.Seed is set #10
Comments
jdhayford
changed the title
Petnames are not random unless rand.Seed is set
Petname generation is not "random" unless rand.Seed is set
May 4, 2019
Good call! I've added it to the README.md sample golang code. If you have
other ideas, sure, go ahead and send a PR.
Cheers,
@dustinkirkland
…On Sat, May 4, 2019 at 11:47 AM Jack Hayford ***@***.***> wrote:
This is fairly obvious after taking a peek at the source and seeing the
use of rand.Intn. That said I think it would be a good idea to add a note
in the Readme about this and recommend setting the seed before generating
any petnames using the library. If this is the case and I'm not missing
something I'd be happy to spin up a PR.
Thanks for the library!
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#10>, or mute the
thread
<https://github.com/notifications/unsubscribe-auth/AAGMZBVGLJAHKSB6JFC6HXLPTW42PANCNFSM4HKZJMIQ>
.
|
Hi ! Cheers :) |
Sure, I'd be happy to take a look! Thanks!
@dustinkirkland
…On Thu, Jun 27, 2019 at 6:15 AM Romain Verduci ***@***.***> wrote:
Hi !
I'm using the lib for test automation and I'd like to have a "non
deterministic" mode so when the tests run multiple times they don't produce
the same test data.
@dustinkirkland <https://github.com/dustinkirkland> I'm happy to submit a
PR for this mode but is that something you would like the lib to support ?
Cheers :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#10?email_source=notifications&email_token=AAGMZBRMUVQE2DSBQVRYBS3P4SOORA5CNFSM4HKZJMI2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYWZPHI#issuecomment-506304413>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAGMZBUHGUVZPD4WFD327CTP4SOORANCNFSM4HKZJMIQ>
.
|
Bios-Marcel
added a commit
to Bios-Marcel/golang-petname
that referenced
this issue
Aug 26, 2023
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
added a commit
to Bios-Marcel/golang-petname
that referenced
this issue
Aug 26, 2023
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is fairly obvious after taking a peek at the source and seeing the use of
rand.Intn
. That said I think it would be a good idea to add a note in the Readme about this and recommend setting the seed before generating any petnames using the library. If this is the case and I'm not missing something I'd be happy to spin up a PR.Thanks for the library!
The text was updated successfully, but these errors were encountered: