io/ioutil package has been deprecated in Go 1.16 that replaces io/ioutil functions

Signed-off-by: Zou Nengren <zouyee1989@gmail.com>
This commit is contained in:
zounengren 2021-10-13 09:10:47 +08:00
parent 0855725370
commit 1f1cad3912
4 changed files with 5 additions and 9 deletions

View File

@ -19,7 +19,6 @@ package fuzz
import ( import (
"context" "context"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
@ -43,7 +42,7 @@ func testEnv() (context.Context, *bolt.DB, func(), error) {
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
ctx = namespaces.WithNamespace(ctx, "testing") ctx = namespaces.WithNamespace(ctx, "testing")
dirname, err := ioutil.TempDir("", "fuzz-") dirname, err := os.MkdirTemp("", "fuzz-")
if err != nil { if err != nil {
return ctx, nil, nil, err return ctx, nil, nil, err
} }
@ -263,7 +262,7 @@ func testDB(opt ...testOpt) (context.Context, *metadata.DB, func(), error) {
o(&topts) o(&topts)
} }
dirname, err := ioutil.TempDir("", "fuzzing-") dirname, err := os.MkdirTemp("", "fuzzing-")
if err != nil { if err != nil {
return ctx, nil, func() { cancel() }, err return ctx, nil, func() { cancel() }, err
} }

View File

@ -21,7 +21,6 @@ package integration
import ( import (
"context" "context"
"io/ioutil"
"net" "net"
"os" "os"
"path/filepath" "path/filepath"
@ -147,7 +146,7 @@ func testFailFastWhenConnectShim(abstract bool, dialFn dialFunc) func(*testing.T
} }
func newTestListener(t testing.TB, abstract bool) (string, net.Listener, func()) { func newTestListener(t testing.TB, abstract bool) (string, net.Listener, func()) {
tmpDir, err := ioutil.TempDir("", "shim-ut-XX") tmpDir, err := os.MkdirTemp("", "shim-ut-XX")
if err != nil { if err != nil {
t.Fatalf("failed to create tmp directory: %v", err) t.Fatalf("failed to create tmp directory: %v", err)
} }

View File

@ -22,7 +22,6 @@ package linux
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"strconv" "strconv"
@ -49,7 +48,7 @@ func TestNewBundle(t *testing.T) {
for i, tc := range tests { for i, tc := range tests {
t.Run(strconv.Itoa(i), func(t *testing.T) { t.Run(strconv.Itoa(i), func(t *testing.T) {
dir, err := ioutil.TempDir("", "test-new-bundle") dir, err := os.MkdirTemp("", "test-new-bundle")
require.NoError(t, err, "failed to create test directory") require.NoError(t, err, "failed to create test directory")
defer os.RemoveAll(dir) defer os.RemoveAll(dir)
work := filepath.Join(dir, "work") work := filepath.Join(dir, "work")

View File

@ -20,7 +20,6 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"strconv" "strconv"
@ -48,7 +47,7 @@ func TestNewBundle(t *testing.T) {
for i, tc := range tests { for i, tc := range tests {
t.Run(strconv.Itoa(i), func(t *testing.T) { t.Run(strconv.Itoa(i), func(t *testing.T) {
dir, err := ioutil.TempDir("", "test-new-bundle") dir, err := os.MkdirTemp("", "test-new-bundle")
require.NoError(t, err, "failed to create test directory") require.NoError(t, err, "failed to create test directory")
defer os.RemoveAll(dir) defer os.RemoveAll(dir)
work := filepath.Join(dir, "work") work := filepath.Join(dir, "work")