mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
all: use os.ReadDir instead of ioutil.ReadDir
The ioutil.ReadDir is deprecated since Go1.16 - see https://tip.golang.org/doc/go1.16#ioutil
VictoriaMetrics requires at least Go1.18, so it is time to switch from io.ReadDir to os.ReadDir
This is a follow-up for 02ca2342ab
This commit is contained in:
parent
06f6de6d47
commit
88e0fe9469
2 changed files with 9 additions and 10 deletions
10
lib/fs/fs.go
10
lib/fs/fs.go
|
@ -269,20 +269,20 @@ func SymlinkRelative(srcPath, dstPath string) error {
|
||||||
|
|
||||||
// CopyDirectory copies all the files in srcPath to dstPath.
|
// CopyDirectory copies all the files in srcPath to dstPath.
|
||||||
func CopyDirectory(srcPath, dstPath string) error {
|
func CopyDirectory(srcPath, dstPath string) error {
|
||||||
fis, err := ioutil.ReadDir(srcPath)
|
des, err := os.ReadDir(srcPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := MkdirAllIfNotExist(dstPath); err != nil {
|
if err := MkdirAllIfNotExist(dstPath); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, fi := range fis {
|
for _, de := range des {
|
||||||
if !fi.Mode().IsRegular() {
|
if !de.Type().IsRegular() {
|
||||||
// Skip non-files
|
// Skip non-files
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
src := filepath.Join(srcPath, fi.Name())
|
src := filepath.Join(srcPath, de.Name())
|
||||||
dst := filepath.Join(dstPath, fi.Name())
|
dst := filepath.Join(dstPath, de.Name())
|
||||||
if err := copyFile(src, dst); err != nil {
|
if err := copyFile(src, dst); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -221,14 +220,14 @@ func tryOpeningQueue(path, name string, chunkFileSize, maxBlockSize, maxPendingB
|
||||||
}
|
}
|
||||||
|
|
||||||
// Locate reader and writer chunks in the path.
|
// Locate reader and writer chunks in the path.
|
||||||
fis, err := ioutil.ReadDir(path)
|
des, err := os.ReadDir(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("cannot read contents of the directory %q: %w", path, err)
|
return nil, fmt.Errorf("cannot read contents of the directory %q: %w", path, err)
|
||||||
}
|
}
|
||||||
for _, fi := range fis {
|
for _, de := range des {
|
||||||
fname := fi.Name()
|
fname := de.Name()
|
||||||
filepath := path + "/" + fname
|
filepath := path + "/" + fname
|
||||||
if fi.IsDir() {
|
if de.IsDir() {
|
||||||
logger.Errorf("skipping unknown directory %q", filepath)
|
logger.Errorf("skipping unknown directory %q", filepath)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue