switch to math/rand/v2 in most places

this allows removing some ugly instantiations of an rng based on the current
time.

Intn is now IntN for our concurrency-safe prng wrapper to match the randv2 api.

v2 exists since go1.22, which we already require.
This commit is contained in:
Mechiel Lukkien
2024-11-29 13:45:19 +01:00
parent 96a3ecd52c
commit de435fceba
9 changed files with 24 additions and 30 deletions

View File

@ -214,12 +214,12 @@ messages are shuffled, with optional random seed.`
hamFiles := listDir(hamDir)
spamFiles := listDir(spamDir)
var rand *mathrand.Rand
var seed int64
if a.seed {
rand = mathrand.New(mathrand.NewSource(time.Now().UnixMilli()))
} else {
rand = mathrand.New(mathrand.NewSource(0))
seed = time.Now().UnixMilli()
}
// Still at math/rand (v1 instead of v2) for potential comparison to earlier test results.
rand := mathrand.New(mathrand.NewSource(seed))
shuffle := func(l []string) {
count := len(l)