You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I have been looking for a good package to walk directories for a while and I stumbled upon this one today. I really love the effort you have made into solving the issue with the path/filepath package provided by the go-team.
However, I have one small issue. I was trying to implement a file name filter and it kind of felt a bit awkward. Here is an example:
In the code sample above, I have implemented a word filter for the file path but if I keep the implementation like this, it will stop on the first math and not continue walking the directory.
We get the proper functionality where the walk only ignores the directory I returned an error for.
This feels a bit awkward because now I am ignoring all errors in the error callback and I don´t want to do that by default. If I want to know which errors are filter(word match) errors I need to do another string check in the error callback function.
Is there possibly a way to implement a file name/path filter in a better way that I am not seeing ? and if not, can I then perhaps take a shot at it and make a PR ?
Regards,
The text was updated successfully, but these errors were encountered:
Ref: #53
Returning the special value `filepath.SkipDir` as an error token is
supported by `filepath.Walk` and by `godirwalk.Walk` to configure the
walk function to not descend further in the directory hierarchy of the
current file system entry.
This change updates the example find-fast program to demonstrate use
of this token error value.
You raise an incredibly valid issue, namely being able to skip a node and its descendants as soon as you come across it in the original callback.
I have updated the find-fast example program to demonstrate how to tell the Walk function how to skip a file system entry, and to not descend into its children.
Please re-open this issue if I misunderstood your request, but I think I have addressed your concerns.
Ref: #53
Returning the special value `filepath.SkipDir` as an error token is
supported by `filepath.Walk` and by `godirwalk.Walk` to configure the
walk function to not descend further in the directory hierarchy of the
current file system entry.
This change updates the example find-fast program to demonstrate use
of this token error value.
Hello, I have been looking for a good package to walk directories for a while and I stumbled upon this one today. I really love the effort you have made into solving the issue with the path/filepath package provided by the go-team.
However, I have one small issue. I was trying to implement a file name filter and it kind of felt a bit awkward. Here is an example:
In the code sample above, I have implemented a word filter for the file path but if I keep the implementation like this, it will stop on the first math and not continue walking the directory.
However if I add an error callback like so:
We get the proper functionality where the walk only ignores the directory I returned an error for.
This feels a bit awkward because now I am ignoring all errors in the error callback and I don´t want to do that by default. If I want to know which errors are filter(word match) errors I need to do another string check in the error callback function.
Is there possibly a way to implement a file name/path filter in a better way that I am not seeing ? and if not, can I then perhaps take a shot at it and make a PR ?
Regards,
The text was updated successfully, but these errors were encountered: