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

@@ -18,7 +18,6 @@ package mount
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
@@ -42,7 +41,7 @@ func checkLookup(t *testing.T, fsType, mntPoint, dir string) {
func testLookup(t *testing.T, fsType string) {
testutil.RequiresRoot(t)
mnt, err := ioutil.TempDir("", "containerd-mountinfo-test-lookup")
mnt, err := os.MkdirTemp("", "containerd-mountinfo-test-lookup")
if err != nil {
t.Fatal(err)
}
@@ -69,7 +68,7 @@ func testLookup(t *testing.T, fsType string) {
assert.Check(t, strings.HasPrefix(loop.Device, "/dev/loop"))
checkLookup(t, fsType, mnt, mnt)
newMnt, err := ioutil.TempDir("", "containerd-mountinfo-test-newMnt")
newMnt, err := os.MkdirTemp("", "containerd-mountinfo-test-newMnt")
if err != nil {
t.Fatal(err)
}
@@ -100,19 +99,19 @@ func TestLookupWithXFS(t *testing.T) {
}
func TestLookupWithOverlay(t *testing.T) {
lower, err := ioutil.TempDir("", "containerd-mountinfo-test-lower")
lower, err := os.MkdirTemp("", "containerd-mountinfo-test-lower")
assert.NilError(t, err)
defer os.RemoveAll(lower)
upper, err := ioutil.TempDir("", "containerd-mountinfo-test-upper")
upper, err := os.MkdirTemp("", "containerd-mountinfo-test-upper")
assert.NilError(t, err)
defer os.RemoveAll(upper)
work, err := ioutil.TempDir("", "containerd-mountinfo-test-work")
work, err := os.MkdirTemp("", "containerd-mountinfo-test-work")
assert.NilError(t, err)
defer os.RemoveAll(work)
overlay, err := ioutil.TempDir("", "containerd-mountinfo-test-overlay")
overlay, err := os.MkdirTemp("", "containerd-mountinfo-test-overlay")
assert.NilError(t, err)
defer os.RemoveAll(overlay)