From aedd6bf6a1c749dffadd7657c078e11e2efc0662 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Tue, 13 Aug 2024 19:56:25 +0200 Subject: [PATCH] Improved Windows support --- src/fs/Walk.go | 2 ++ src/fs/Walk_windows.go | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/fs/Walk_windows.go 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 + }) +}