bmatcuk / doublestar

Implements support for double star (**) matches in golang's path.Match and filepath.Glob.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

path separator on Windows

stu0292 opened this issue · comments

I don't know how much you're trying to mimic path/filepath.Glob with this but on Windows, path/filepath.Glob converts forward slash to the appropriate path separator.

fmt.Println(filepath.Glob("*/*/*.txt"))                      // rel path to my txt files
fmt.Println(doublestar.Glob("**\\*.txt"))                    // works on windows only
fmt.Println(doublestar.Glob(filepath.FromSlash("**/*.txt"))) // FromSlash conversion , should work cross platform
fmt.Println(doublestar.Glob("**/*.txt"))                     // Doesn't work on windows

Using filepath.FromSlash works for me in my current problem but could be useful to use this in doublestar.Glob and Match anyway?

Neat package :)

Watch out when passing in globs in as command line arguments - os.Args seems to try to resolve the arg if there are any files that match the glob in the current directory. Quoting the argument seems to workaround this...

Ah, interesting... I'll see what I can come up with =) I just got back from vacation, so it might be a couple days. Thanks!

So, sounds like filepath.FromSlash should fix the issue. I've made Glob call FromSlash internally. Let me know if you have any issues! =)