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
So I've been coding in Golang for a while and there are a few bugs here and there, but one of the issues I have with the standard library is that there are two random packages, which doesn't make sense because all the functions from one package overlap with the functions from the other, so I was wondering if we could have a single package that can do everything.
There will be less code for Golang maintainers to maintain, and it will be easier for new Golang users to figure out what to use, We may progressively remove the crypto/rand package and just use the math/rand package after that.
I'm not just talking about one package; I've seen so many identical functions that accomplish the exact same thing that it's ridiculous.
The text was updated successfully, but these errors were encountered:
ghost
changed the title
Remove crypto/rand package.
Duplicate functions should be removed from the standard library.
Oct 6, 2021
mknyszek
changed the title
Duplicate functions should be removed from the standard library.
all: duplicate functions should be removed from the standard library
Oct 6, 2021
The duplication is there for a reason, as a general rule. crypto/rand and math/rand in particular expose the same API, but target different audiences. math/rand provides a pseudo-random number generator that is relatively fast, and suitable for a wide range of applications (random number generators in tests, for games, for rate limiting, etc.). However that generator is not cryptographically secure, meaning that given some range of attack vectors, it's possible to write an algorithm that figures out what future values will be. Because cryptography applications rely on the random number being hard to predict, that makes math/rand a bad choice. Hence the existence of crypto/rand, which provides these guarantees.
Closing this issue unless you have other specific examples. Please be aware that the Go project cannot remove any functions from standard library packages in order to maintain the Go 1 backwards compatibility guarantee. There may be situations in which some functions can be written in terms of others (and this does happen, see some recent io/ioutil functions being rewritten in terms of their non-deprecated os and io counterparts), so that would be the way forward in any of these situations. Please feel free to contribute any such deduplications directly, no need to file an issue. See https://golang.org/doc/contribute.
Again, do note that some actual duplication exists for a reason. There is one example that pops into my head, but that one, at the moment, is unavoidable (specifically, math/bits and runtime/internal/sys have some duplicate code).
Hello,
So I've been coding in Golang for a while and there are a few bugs here and there, but one of the issues I have with the standard library is that there are two random packages, which doesn't make sense because all the functions from one package overlap with the functions from the other, so I was wondering if we could have a single package that can do everything.
There will be less code for Golang maintainers to maintain, and it will be easier for new Golang users to figure out what to use, We may progressively remove the
crypto/rand
package and just use themath/rand
package after that.I'm not just talking about one package; I've seen so many identical functions that accomplish the exact same thing that it's ridiculous.
The text was updated successfully, but these errors were encountered: