Merge pull request #1892 from stevvooe/use-math-rand-reader
testutil, storage: use math/rand.Read where possible
This commit is contained in:
@@ -1168,10 +1168,7 @@ func randomFilename(length int64) string {
|
||||
var randomBytes = make([]byte, 128<<20)
|
||||
|
||||
func init() {
|
||||
// increase the random bytes to the required maximum
|
||||
for i := range randomBytes {
|
||||
randomBytes[i] = byte(rand.Intn(2 << 8))
|
||||
}
|
||||
_, _ = rand.Read(randomBytes) // always returns len(randomBytes) and nil error
|
||||
}
|
||||
|
||||
func randomContents(length int64) []byte {
|
||||
|
@@ -2,7 +2,6 @@ package storage
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/rand"
|
||||
"io"
|
||||
mrand "math/rand"
|
||||
"os"
|
||||
@@ -16,7 +15,7 @@ import (
|
||||
func TestSimpleRead(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
content := make([]byte, 1<<20)
|
||||
n, err := rand.Read(content)
|
||||
n, err := mrand.Read(content)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error building random data: %v", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user