godirwalk
godirwalk copied to clipboard
fix: ignore EOF error on Windows directory scanning
In #68, the scanner now returns any error that was encountered. On Windows, the call to Readdir will return an EOF when it is done reading a directory.
I believe the desired behavior is to throw an error on any actual errors, but in the case of EOF, continue on to the next directory. As such, check for the EOF and return no error while releasing resources.
A user can test this PR by using the walk-fast example:
go run ./examples/walk-fast/main.go --verbose C:/users/powersj/godirwalk
Currently, this will throw an EOF error after the first directory. With this fix, all the sub-directories will be traversed and return successfully.
fixes: #70
Hmm the test error is:
The Go task failed with an error: Error: The process 'C:\hostedtoolcache\windows\go\1.13.0\x64\bin\go.exe' failed with exit code 2
This also appears on master currently, but error code 1.
Here is local running, with go1.19:
PS C:\Users\powersj\godirwalk> go test ./...
ok github.com/karrick/godirwalk 0.187s
? github.com/karrick/godirwalk/examples/remove-empty-directories [no test files]
? github.com/karrick/godirwalk/examples/scanner [no test files]
? github.com/karrick/godirwalk/examples/sizes [no test files]
? github.com/karrick/godirwalk/examples/walk-fast [no test files]
? github.com/karrick/godirwalk/examples/walk-stdlib [no test files]
@xuyang2 thanks! seems to resolved the test failure as well :)
@karrick anything I can do to help this along?
@xuyang2 We're also interested in this fix - is there an estimate as to when this is going to be released?
@karrick Is this project still active?