Fixed fs package tests on Windows
This commit is contained in:
@ -2,23 +2,27 @@
|
||||
|
||||
package fs
|
||||
|
||||
import (
|
||||
"io/fs"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
import "os"
|
||||
|
||||
// Walk calls your callback function for every file name inside the directory.
|
||||
// It doesn't distinguish between files and directories.
|
||||
func Walk(directory string, callBack func(string)) error {
|
||||
return filepath.WalkDir(directory, func(path string, d fs.DirEntry, err error) error {
|
||||
fileName := d.Name()
|
||||
f, err := os.Open(directory)
|
||||
|
||||
if strings.HasPrefix(fileName, ".") {
|
||||
return filepath.SkipDir
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
callBack(fileName)
|
||||
return nil
|
||||
})
|
||||
files, err := f.Readdirnames(0)
|
||||
f.Close()
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, file := range files {
|
||||
callBack(file)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user