refactor: move from io/ioutil to io and os package

The io/ioutil package has been deprecated as of Go 1.16, see
https://golang.org/doc/go1.16#ioutil. This commit replaces the existing
io/ioutil functions with their new definitions in io and os packages.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
Eng Zer Jun
2021-09-10 20:28:11 +08:00
parent c16be1a5e2
commit 50da673592
126 changed files with 291 additions and 399 deletions

View File

@@ -21,7 +21,6 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"math/rand"
"os"
"runtime"
@@ -104,7 +103,7 @@ func makeTest(t *testing.T, name string, storeFn func(ctx context.Context, root
ctx := context.WithValue(context.Background(), nameKey{}, name)
ctx = logtest.WithT(ctx, t)
tmpDir, err := ioutil.TempDir("", "content-suite-"+name+"-")
tmpDir, err := os.MkdirTemp("", "content-suite-"+name+"-")
if err != nil {
t.Fatal(err)
}
@@ -782,7 +781,7 @@ func checkSmallBlob(ctx context.Context, t *testing.T, store content.Store) {
}
defer ra.Close()
r := io.NewSectionReader(ra, 0, readSize)
b, err := ioutil.ReadAll(r)
b, err := io.ReadAll(r)
if err != nil {
t.Fatal(err)
}
@@ -1080,7 +1079,7 @@ func createContent(size int64) ([]byte, digest.Digest) {
// test runs. An atomic integer works just good enough for this.
seed := atomic.AddInt64(&contentSeed, 1)
b, err := ioutil.ReadAll(io.LimitReader(rand.New(rand.NewSource(seed)), size))
b, err := io.ReadAll(io.LimitReader(rand.New(rand.NewSource(seed)), size))
if err != nil {
panic(err)
}