diff --git a/src/fs/Walk.go b/src/fs/Walk.go index ce22ac5..0a169ab 100644 --- a/src/fs/Walk.go +++ b/src/fs/Walk.go @@ -1,3 +1,5 @@ +//go:build linux || darwin + package fs import ( diff --git a/src/fs/Walk_windows.go b/src/fs/Walk_windows.go new file mode 100644 index 0000000..37e284c --- /dev/null +++ b/src/fs/Walk_windows.go @@ -0,0 +1,22 @@ +//go:build windows + +package fs + +import ( + "io/fs" + "path/filepath" + "strings" +) + +// 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 { + if strings.HasPrefix(d.Name(), ".") { + return filepath.SkipDir + } + + callBack(path) + return nil + }) +}