-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
proposal: Go 2: move math/rand to x/math/rand #24800
Comments
This same argument applies to literally every other package in the standard library; and yet you need to have something in it, right? : ) Unless go2 goes in the "move everything outside of the main repository" direction, I don't see how it could be reasonable to move a fundamental package like the one that generates random numbers out of stdlib, while still having a lot of other much less fundamental packages in it. While it's true that we have been bitten in the past by the impossibility to fix fundamental deficiencies in the package's underling randomness source without breaking retro-compatibility, a new, clean implementation that fixes the most glaring issues with the package, like Rob proposed in #21835, could very well fit into the go2 standard library.
There's a (very prominent) warning at the top of the doc, in the package overview, about this:
And frankly, I doubt that a user that doesn't understand the difference between secure and non-secure random number generation will be able to write a cryptographically-secure application, even if we move |
@ianlancetaylor I have no problems with implementing #21835 in Go 2. @ALTree I agree with you, but why does the stdlib even need to offer two random number generators? Do users care? I (want to) assume anyone really needing |
Thanks. I'm going to close this issue in favor of #21835. Discussions of why we need both math/rand and crypto/rand are perhaps best held on golang-dev. |
math/rand
has several known and documented problems (see #21835) and it's easily mistaken forcrypto/rand
(see #20661). This is a proposal to move it out of the standard library, which would give several advantages.crypto/rand
)The
go fix
tool could rewrite imports tox/math/rand
or default tocrypto/rand
. There are real use cases for a deterministic generator (jitter, tests, etc) so we shouldn't remove it entirely. We should gather uses ofmath/rand
thatcrypto/rand
doesn't satisfy.The text was updated successfully, but these errors were encountered: