Skip to content

Commit

Permalink
remove ioutil
Browse files Browse the repository at this point in the history
It is deprecated.
  • Loading branch information
josharian committed Dec 13, 2022
1 parent e115f2e commit 9639e6b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
6 changes: 3 additions & 3 deletions node.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package notify

import (
"errors"
"io/ioutil"
"io/fs"
"os"
"path/filepath"
)
Expand Down Expand Up @@ -78,12 +78,12 @@ Traverse:
}
// TODO(rjeczalik): tolerate open failures - add failed names to
// AddDirError and notify users which names are not added to the tree.
fi, err := ioutil.ReadDir(nd.Name)
fi, err := os.ReadDir(nd.Name)
if err != nil {
return err
}
for _, fi := range fi {
if fi.Mode()&(os.ModeSymlink|os.ModeDir) == os.ModeDir {
if fi.Type()&(fs.ModeSymlink|fs.ModeDir) == fs.ModeDir {
name := filepath.Join(nd.Name, fi.Name())
stack = append(stack, nd.addchild(name, name[len(nd.Name)+1:]))
}
Expand Down
3 changes: 1 addition & 2 deletions notify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ package notify

import (
"errors"
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand Down Expand Up @@ -162,7 +161,7 @@ func TestRecreated(t *testing.T) {
time.Sleep(100 * time.Millisecond)

// Create a file
mustT(t, ioutil.WriteFile(file, []byte("abc"), 0666))
mustT(t, os.WriteFile(file, []byte("abc"), 0666))
}
timeout := time.After(5 * time.Second)
checkCreated := func() {
Expand Down
3 changes: 1 addition & 2 deletions testing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package notify
import (
"bufio"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"reflect"
Expand Down Expand Up @@ -105,7 +104,7 @@ func tmptree(root, list string) (string, error) {
}
defer f.Close()
if root == "" {
if root, err = ioutil.TempDir(vfs()); err != nil {
if root, err = os.MkdirTemp(vfs()); err != nil {
return "", err
}
}
Expand Down
5 changes: 2 additions & 3 deletions util_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
package notify

import (
"io/ioutil"
"os"
"path/filepath"
"testing"
)

func tmpfile(s string) (string, error) {
f, err := ioutil.TempFile(filepath.Split(s))
f, err := os.CreateTemp(filepath.Split(s))
if err != nil {
return "", err
}
Expand Down Expand Up @@ -96,7 +95,7 @@ func TestCanonicalCircular(t *testing.T) {

// issue #83
func TestCanonical_RelativeSymlink(t *testing.T) {
dir, err := ioutil.TempDir(wd, "")
dir, err := os.MkdirTemp(wd, "")
if err != nil {
t.Fatalf("TempDir()=%v", err)
}
Expand Down

0 comments on commit 9639e6b

Please sign in to comment.