You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, since go 1.20, rand is automatically seeded, unless explicitly disabled:
// Prior to Go 1.20, the generator was seeded like Seed(1) at program startup.
// To force the old behavior, call Seed(1) at program startup.
// Alternately, set GODEBUG=randautoseed=0 in the environment
// before making any calls to functions in this package.
Maybe you want to factor this behaviour in, not sure. For me personally, I called rand.Seed manually beforehand and simply had no change in behaviour. But for people expecting something deterministic, this might be confusing. Additionaly, this library might want to stop using globalrand and instead allow specifying a source, as this makes it easier to use within projects that use randomness for other purposes.
The text was updated successfully, but these errors were encountered:
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.
Fixesdustinkirkland#10 (The readme and docs explain this, therefore I consider this
solved, as it is by design and not a bug)
Fixesdustinkirkland#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.
Fixesdustinkirkland#10 (The readme and docs explain this, therefore I consider this
solved, as it is by design and not a bug)
Fixesdustinkirkland#15
You've got this function calling rand.Seed for a non deterministic mode.
golang-petname/petname.go
Line 45 in e794b93
However, since go 1.20, rand is automatically seeded, unless explicitly disabled:
Maybe you want to factor this behaviour in, not sure. For me personally, I called rand.Seed manually beforehand and simply had no change in behaviour. But for people expecting something deterministic, this might be confusing. Additionaly, this library might want to stop using globalrand and instead allow specifying a source, as this makes it easier to use within projects that use randomness for other purposes.
The text was updated successfully, but these errors were encountered: