Closed JeffreyVdb closed 1 year ago
Just for clearness. On windows, the return value of this function for a subdirectory called "foobar\something' would be:
\foobar\something
instead of
foobar/something
Hey, thanks for your contribution. Please allow for some time to test this as this is Windows specific.
The last commit should also be applicable to Linux. It should endlessly loop on all platforms (before this fix).
Tested and merged, thanks @JeffreyVdb
Before this commit, the root directory would be removed which leaves a trailing file separator character in the beginning. This would then be trimmed by using strings.TrimPrefix. The problem here is that it uses a hardcoded file separator character which won't work on Windows because Windows uses a backslash instead of a forward slash.
Using filepath.Rel to get the directory relative to the root directory will not leave a separator character in the beginning.
It's also important to use filepath.ToSlash which will translate every file separator character to the forward slash.
This commit makes discovery work on Windows which it didn't before.