mirror of https://github.com/docker/compose.git
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:
parent
c08e07714a
commit
7d6ee74e62
|
@ -4,7 +4,6 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
@ -72,7 +71,7 @@ func TestEventOrdering(t *testing.T) {
|
||||||
for i, dir := range dirs {
|
for i, dir := range dirs {
|
||||||
base := fmt.Sprintf("%d.txt", i)
|
base := fmt.Sprintf("%d.txt", i)
|
||||||
p := filepath.Join(dir, base)
|
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 {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -237,7 +236,7 @@ func TestRemoveAndAddBack(t *testing.T) {
|
||||||
path := filepath.Join(f.paths[0], "change")
|
path := filepath.Join(f.paths[0], "change")
|
||||||
|
|
||||||
d1 := []byte("hello\ngo\n")
|
d1 := []byte("hello\ngo\n")
|
||||||
err := ioutil.WriteFile(path, d1, 0644)
|
err := os.WriteFile(path, d1, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -252,7 +251,7 @@ func TestRemoveAndAddBack(t *testing.T) {
|
||||||
f.assertEvents(path)
|
f.assertEvents(path)
|
||||||
f.events = nil
|
f.events = nil
|
||||||
|
|
||||||
err = ioutil.WriteFile(path, d1, 0644)
|
err = os.WriteFile(path, d1, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -273,7 +272,7 @@ func TestSingleFile(t *testing.T) {
|
||||||
f.fsync()
|
f.fsync()
|
||||||
|
|
||||||
d2 := []byte("hello\nworld\n")
|
d2 := []byte("hello\nworld\n")
|
||||||
err := ioutil.WriteFile(path, d2, 0644)
|
err := os.WriteFile(path, d2, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -303,7 +302,7 @@ func TestWriteGoodLink(t *testing.T) {
|
||||||
f := newNotifyFixture(t)
|
f := newNotifyFixture(t)
|
||||||
|
|
||||||
goodFile := filepath.Join(f.paths[0], "goodFile")
|
goodFile := filepath.Join(f.paths[0], "goodFile")
|
||||||
err := ioutil.WriteFile(goodFile, []byte("hello"), 0644)
|
err := os.WriteFile(goodFile, []byte("hello"), 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package watch
|
package watch
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
@ -18,7 +17,7 @@ func NewDir(prefix string) (*TempDir, error) {
|
||||||
|
|
||||||
// NewDir creates a new TempDir at the given root.
|
// NewDir creates a new TempDir at the given root.
|
||||||
func NewDirAtRoot(root, prefix string) (*TempDir, error) {
|
func NewDirAtRoot(root, prefix string) (*TempDir, error) {
|
||||||
tmpDir, err := ioutil.TempDir(root, prefix)
|
tmpDir, err := os.MkdirTemp(root, prefix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -42,7 +41,7 @@ func NewDirAtSlashTmp(prefix string) (*TempDir, error) {
|
||||||
|
|
||||||
// d.NewDir creates a new TempDir under d
|
// d.NewDir creates a new TempDir under d
|
||||||
func (d *TempDir) NewDir(prefix string) (*TempDir, error) {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue