Handle rand deprecations in go 1.20

Signed-off-by: James Hewitt <james.hewitt@uk.ibm.com>
This commit is contained in:
James Hewitt
2023-08-27 11:06:16 +01:00
parent 0eb8fee87e
commit 1a3e73cb84
8 changed files with 12 additions and 10 deletions

View File

@@ -3,6 +3,7 @@ package testutil
import (
"archive/tar"
"bytes"
crand "crypto/rand"
"fmt"
"io"
mrand "math/rand"
@@ -45,7 +46,7 @@ func CreateRandomTarFile() (rs io.ReadSeeker, dgst digest.Digest, err error) {
randomData := make([]byte, fileSize)
// Fill up the buffer with some random data.
n, err := mrand.Read(randomData)
n, err := crand.Read(randomData)
if n != len(randomData) {
return nil, "", fmt.Errorf("short read creating random reader: %v bytes != %v bytes", n, len(randomData))