Skip to content

Commit ad09f55

Browse files
committed
Removed deprecated call to io/ioutil
1 parent b3ef88d commit ad09f55

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

Diff for: paths.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ package paths
3232
import (
3333
"fmt"
3434
"io"
35-
"io/ioutil"
3635
"os"
3736
"path/filepath"
3837
"strings"
@@ -418,14 +417,14 @@ func (p *Path) Chtimes(atime, mtime time.Time) error {
418417

419418
// ReadFile reads the file named by filename and returns the contents
420419
func (p *Path) ReadFile() ([]byte, error) {
421-
return ioutil.ReadFile(p.path)
420+
return os.ReadFile(p.path)
422421
}
423422

424423
// WriteFile writes data to a file named by filename. If the file
425424
// does not exist, WriteFile creates it otherwise WriteFile truncates
426425
// it before writing.
427426
func (p *Path) WriteFile(data []byte) error {
428-
return ioutil.WriteFile(p.path, data, os.FileMode(0644))
427+
return os.WriteFile(p.path, data, os.FileMode(0644))
429428
}
430429

431430
// WriteToTempFile writes data to a newly generated temporary file.

Diff for: readdir.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
package paths
3131

3232
import (
33-
"io/ioutil"
33+
"os"
3434
"strings"
3535
)
3636

@@ -41,7 +41,7 @@ type ReadDirFilter func(file *Path) bool
4141
// ReadDir returns a PathList containing the content of the directory
4242
// pointed by the current Path. The resulting list is filtered by the given filters chained.
4343
func (p *Path) ReadDir(filters ...ReadDirFilter) (PathList, error) {
44-
infos, err := ioutil.ReadDir(p.path)
44+
infos, err := os.ReadDir(p.path)
4545
if err != nil {
4646
return nil, err
4747
}
@@ -69,7 +69,7 @@ func (p *Path) ReadDir(filters ...ReadDirFilter) (PathList, error) {
6969
// ReadDirRecursive returns a PathList containing the content of the directory
7070
// and its subdirectories pointed by the current Path
7171
func (p *Path) ReadDirRecursive() (PathList, error) {
72-
infos, err := ioutil.ReadDir(p.path)
72+
infos, err := os.ReadDir(p.path)
7373
if err != nil {
7474
return nil, err
7575
}
@@ -101,7 +101,7 @@ func (p *Path) ReadDirRecursive() (PathList, error) {
101101
// - `filters` are the filters that are checked to determine if the entry should be
102102
// added to the resulting PathList
103103
func (p *Path) ReadDirRecursiveFiltered(recursionFilter ReadDirFilter, filters ...ReadDirFilter) (PathList, error) {
104-
infos, err := ioutil.ReadDir(p.path)
104+
infos, err := os.ReadDir(p.path)
105105
if err != nil {
106106
return nil, err
107107
}

0 commit comments

Comments
 (0)