cleanup deprecated ioutil functions (#5919)

Signed-off-by: Nick Santos <nick.santos@docker.com>

Signed-off-by: Nick Santos <nick.santos@docker.com>
This commit is contained in:
Nick Santos 2022-08-12 16:17:41 -04:00 committed by Nicolas De loof
parent c08e07714a
commit 7d6ee74e62
2 changed files with 7 additions and 9 deletions

View File

@ -4,7 +4,6 @@ import (
"bytes"
"context"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"runtime"
@ -72,7 +71,7 @@ func TestEventOrdering(t *testing.T) {
for i, dir := range dirs {
base := fmt.Sprintf("%d.txt", i)
p := filepath.Join(dir, base)
err := ioutil.WriteFile(p, []byte(base), os.FileMode(0777))
err := os.WriteFile(p, []byte(base), os.FileMode(0777))
if err != nil {
t.Fatal(err)
}
@ -237,7 +236,7 @@ func TestRemoveAndAddBack(t *testing.T) {
path := filepath.Join(f.paths[0], "change")
d1 := []byte("hello\ngo\n")
err := ioutil.WriteFile(path, d1, 0644)
err := os.WriteFile(path, d1, 0644)
if err != nil {
t.Fatal(err)
}
@ -252,7 +251,7 @@ func TestRemoveAndAddBack(t *testing.T) {
f.assertEvents(path)
f.events = nil
err = ioutil.WriteFile(path, d1, 0644)
err = os.WriteFile(path, d1, 0644)
if err != nil {
t.Fatal(err)
}
@ -273,7 +272,7 @@ func TestSingleFile(t *testing.T) {
f.fsync()
d2 := []byte("hello\nworld\n")
err := ioutil.WriteFile(path, d2, 0644)
err := os.WriteFile(path, d2, 0644)
if err != nil {
t.Fatal(err)
}
@ -303,7 +302,7 @@ func TestWriteGoodLink(t *testing.T) {
f := newNotifyFixture(t)
goodFile := filepath.Join(f.paths[0], "goodFile")
err := ioutil.WriteFile(goodFile, []byte("hello"), 0644)
err := os.WriteFile(goodFile, []byte("hello"), 0644)
if err != nil {
t.Fatal(err)
}

View File

@ -1,7 +1,6 @@
package watch
import (
"io/ioutil"
"os"
"path/filepath"
)
@ -18,7 +17,7 @@ func NewDir(prefix string) (*TempDir, error) {
// NewDir creates a new TempDir at the given root.
func NewDirAtRoot(root, prefix string) (*TempDir, error) {
tmpDir, err := ioutil.TempDir(root, prefix)
tmpDir, err := os.MkdirTemp(root, prefix)
if err != nil {
return nil, err
}
@ -42,7 +41,7 @@ func NewDirAtSlashTmp(prefix string) (*TempDir, error) {
// d.NewDir creates a new TempDir under d
func (d *TempDir) NewDir(prefix string) (*TempDir, error) {
d2, err := ioutil.TempDir(d.dir, prefix)
d2, err := os.MkdirTemp(d.dir, prefix)
if err != nil {
return nil, err
}