fs: update use of math/rand to modern practice

This commit is contained in:
Nick Craig-Wood 2023-12-01 16:31:51 +00:00
parent 7aa066cff8
commit 208e49ce4b
3 changed files with 6 additions and 6 deletions

View File

@ -1,10 +1,10 @@
package quickxorhash package quickxorhash
import ( import (
"crypto/rand"
"encoding/base64" "encoding/base64"
"fmt" "fmt"
"hash" "hash"
"math/rand"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
@ -171,7 +171,9 @@ var _ hash.Hash = (*quickXorHash)(nil)
func BenchmarkQuickXorHash(b *testing.B) { func BenchmarkQuickXorHash(b *testing.B) {
b.SetBytes(1 << 20) b.SetBytes(1 << 20)
buf := make([]byte, 1<<20) buf := make([]byte, 1<<20)
rand.Read(buf) n, err := rand.Read(buf)
require.NoError(b, err)
require.Equal(b, len(buf), n)
h := New() h := New()
b.ResetTimer() b.ResetTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {

View File

@ -10,7 +10,6 @@ import (
"fmt" "fmt"
"io" "io"
"log" "log"
"math/rand"
"os" "os"
"path" "path"
"path/filepath" "path/filepath"
@ -52,8 +51,7 @@ var (
// Seed the random number generator // Seed the random number generator
func init() { func init() {
rand.Seed(time.Now().UnixNano()) _ = random.Seed()
} }
// Initialise rclone for testing // Initialise rclone for testing

View File

@ -31,7 +31,7 @@ var (
// Seed the random number generator // Seed the random number generator
func init() { func init() {
rand.Seed(time.Now().UnixNano()) _ = random.Seed()
} }