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
### Motivation
The Go 1.20 release deprecated the `rand.Seed` function, noting that programs should use the `rand.New(rand.NewSource(seed))` method instead. This change was made because using `rand.Seed` affects the global random number generator, which can lead to unexpected behavior in concurrent programs. By updating to the recommended API, we improve the code's forward compatibility and follow Go's best practices for random number generation.
### Modifications
Replaced all occurrences of `rand.Seed(time.Now().UnixNano())` with `rand.New(rand.NewSource(time.Now().UnixNano()))`
Updated variable assignments to use the new random generator instance where applicable
Maintained the same seed behavior (using current nanosecond time) but now with proper instance isolation
Verifying this change
Make sure that the change passes the CI checks.
This change is a trivial rework / code cleanup without any test coverage. The modification doesn't change the logical behavior of the code, only updates it to use the non-deprecated API.
---------
Signed-off-by: Young Xu <[email protected]>
0 commit comments