-
-
Notifications
You must be signed in to change notification settings - Fork 475
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
[cleanup] Remove Deprecated math/rand.Seed Usage #2675
Conversation
This commit removes the use of the deprecated math/rand.Seed method. Signed-off-by: Takafumi Miyanaga <miya.org.0309@gmail.com> Signed-off-by: orangekame3 <miya.org.0309@gmail.com>
ecf31ca
to
3e1ea24
Compare
This commit fixes golangci-lint error. ``` Signed-off-by: orangekame3 <miya.org.0309@gmail.com>
checked ⤵
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few comments, should be fine to merge once fixed.
@@ -9,18 +9,18 @@ import ( | |||
"time" | |||
) | |||
|
|||
var gr *rand.Rand |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we maybe have a more explicit, longer variable name if this is a global variable?
"crypto/rand" | ||
crand "crypto/rand" | ||
"fmt" | ||
"io" | ||
mrand "math/rand" | ||
"math/rand" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means now the whole file is using math/rand
instead of crypto/rand
when it's calling rand
, that's a bad idea, makes code review too annoying.
crand.Reader = strings.NewReader("") | ||
oldrand := gr | ||
// if we seed math/rand with 1789, the first "random number" will be 42 | ||
gr = rand.New(rand.NewSource(1789)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hence the global variable. I understand better why you need one below, but really its name should be more explicit.
Due to the lack of activity I assume the author lost interest in this PR. As we can't merge it as-is I'm closing it. Feel free to re-open once you have addressed the open comments. |
Issue
#2650
Description
This commit removes the use of the deprecated math/rand.Seed method.
Checked
▼make test