Replace deprecated ioutil

As of Go 1.16, the same functionality is now provided by package io or
package os, and those implementations should be preferred in new code.
This commit is contained in:
albertony
2022-08-20 16:38:02 +02:00
committed by Nick Craig-Wood
parent 776e5ea83a
commit 5d6b8141ec
108 changed files with 295 additions and 359 deletions

View File

@ -3,7 +3,6 @@ package file
import (
"fmt"
"io"
"io/ioutil"
"os"
"path"
"runtime"
@ -16,7 +15,7 @@ import (
// This lists dir and checks the listing is as expected without checking the size
func checkListingNoSize(t *testing.T, dir string, want []string) {
var got []string
nodes, err := ioutil.ReadDir(dir)
nodes, err := os.ReadDir(dir)
require.NoError(t, err)
for _, node := range nodes {
got = append(got, fmt.Sprintf("%s,%v", node.Name(), node.IsDir()))
@ -27,10 +26,12 @@ func checkListingNoSize(t *testing.T, dir string, want []string) {
// This lists dir and checks the listing is as expected
func checkListing(t *testing.T, dir string, want []string) {
var got []string
nodes, err := ioutil.ReadDir(dir)
nodes, err := os.ReadDir(dir)
require.NoError(t, err)
for _, node := range nodes {
got = append(got, fmt.Sprintf("%s,%d,%v", node.Name(), node.Size(), node.IsDir()))
info, err := node.Info()
assert.NoError(t, err)
got = append(got, fmt.Sprintf("%s,%d,%v", node.Name(), info.Size(), node.IsDir()))
}
assert.Equal(t, want, got)
}