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,6 @@
package integration
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
@@ -36,7 +35,7 @@ func createRegularFile(basePath, content string) (string, error) {
}
newFile := filepath.Join(newFolder, "foo.txt")
err = ioutil.WriteFile(newFile, []byte(content), 0644)
err = os.WriteFile(newFile, []byte(content), 0644)
return filepath.Join("regular", "foo.txt"), err
}
@@ -83,11 +82,11 @@ func TestContainerSymlinkVolumes(t *testing.T) {
} {
testCase := testCase // capture range variable
t.Run(name, func(t *testing.T) {
testPodLogDir, err := ioutil.TempDir("", "symlink-test")
testPodLogDir, err := os.MkdirTemp("", "symlink-test")
require.NoError(t, err)
defer os.RemoveAll(testPodLogDir)
testVolDir, err := ioutil.TempDir("", "symlink-test-vol")
testVolDir, err := os.MkdirTemp("", "symlink-test-vol")
require.NoError(t, err)
defer os.RemoveAll(testVolDir)
@@ -137,7 +136,7 @@ func TestContainerSymlinkVolumes(t *testing.T) {
return false, nil
}, time.Second, 30*time.Second))
output, err := ioutil.ReadFile(filepath.Join(testPodLogDir, containerName))
output, err := os.ReadFile(filepath.Join(testPodLogDir, containerName))
assert.NoError(t, err)
assert.Contains(t, string(output), content)