From 688c4eb4462ad7dcb0372f40b323cbcf9c8205d8 Mon Sep 17 00:00:00 2001 From: Kaiyi Li Date: Mon, 8 Jul 2024 07:41:41 -0700 Subject: [PATCH] Fix ignore on Windows `fileMatches` will receive paths with native path separators(i.e. `\` on Windows). Per the [doc](https://github.com/bmatcuk/doublestar/tree/v4?tab=readme-ov-file#match) `doublestar.Match` doesn't work as expected with `\`, and `filepath.ToSlash()` should be used to handle such case. --- main.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main.go b/main.go index b4cdd69..f46e819 100644 --- a/main.go +++ b/main.go @@ -230,6 +230,8 @@ func walk(ch chan<- *file, start string) error { // fileMatches determines if path matches one of the provided file patterns. // Patterns are assumed to be valid. func fileMatches(path string, patterns []string) bool { + // handle both \ and / + path = filepath.ToSlash(path) for _, p := range patterns { // ignore error, since we assume patterns are valid if match, _ := doublestar.Match(p, path); match {