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

@@ -17,7 +17,7 @@
package metadata
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
@@ -28,7 +28,7 @@ import (
)
func TestHasSharedLabel(t *testing.T) {
tmpdir, err := ioutil.TempDir("", "bucket-testing-")
tmpdir, err := os.MkdirTemp("", "bucket-testing-")
if err != nil {
t.Error(err)
}
@@ -64,7 +64,7 @@ func TestHasSharedLabel(t *testing.T) {
}
func TestGetShareableBucket(t *testing.T) {
tmpdir, err := ioutil.TempDir("", "bucket-testing-")
tmpdir, err := os.MkdirTemp("", "bucket-testing-")
if err != nil {
t.Error(err)
}

View File

@@ -19,7 +19,6 @@ package metadata
import (
"context"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"reflect"
@@ -715,7 +714,7 @@ func testEnv(t *testing.T) (context.Context, *bolt.DB, func()) {
ctx = namespaces.WithNamespace(ctx, "testing")
ctx = logtest.WithT(ctx, t)
dirname, err := ioutil.TempDir("", strings.Replace(t.Name(), "/", "_", -1)+"-")
dirname, err := os.MkdirTemp("", strings.Replace(t.Name(), "/", "_", -1)+"-")
if err != nil {
t.Fatal(err)
}

View File

@@ -21,7 +21,6 @@ import (
"encoding/binary"
"fmt"
"io"
"io/ioutil"
"math/rand"
"os"
"path/filepath"
@@ -74,7 +73,7 @@ func testDB(t *testing.T, opt ...testOpt) (context.Context, *DB, func()) {
o(&topts)
}
dirname, err := ioutil.TempDir("", strings.Replace(t.Name(), "/", "_", -1)+"-")
dirname, err := os.MkdirTemp("", strings.Replace(t.Name(), "/", "_", -1)+"-")
if err != nil {
t.Fatal(err)
}
@@ -765,7 +764,7 @@ type testLease struct {
}
func newStores(t testing.TB) (*DB, content.Store, snapshots.Snapshotter, func()) {
td, err := ioutil.TempDir("", "gc-test-")
td, err := os.MkdirTemp("", "gc-test-")
if err != nil {
t.Fatal(err)
}

View File

@@ -19,7 +19,6 @@ package metadata
import (
"context"
"io"
"io/ioutil"
"math/rand"
"os"
"path/filepath"
@@ -389,7 +388,7 @@ func TestGCRefs(t *testing.T) {
}
func newDatabase() (*bolt.DB, func(), error) {
td, err := ioutil.TempDir("", "gc-roots-")
td, err := os.MkdirTemp("", "gc-roots-")
if err != nil {
return nil, nil, err
}