-
Notifications
You must be signed in to change notification settings - Fork 18k
path/filepath: Walk: inconsistent normalization of first matched object name #22489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
there are too many places where we assume the This is what I found in golang itself: |
I agree. |
Or maybe, if not putting into this version, due the possible breakes, maybe add as a proposal for Go2. |
While My reasoning is more philosophical than technical. I like functions to bear only one responsibility. If we make the srcClean := filepath.Clean(src)
err := filepath.Walk(
srcClean,
func(fn string, fi os.FileInfo, er error) error {
... Additionally it would be great to keep How about an added paragraph along the lines of:
Of course, if someone knows of a no-cost natural and portable |
This is happening because I think we should just document it. |
@ianlancetaylor did not realize that - thank you for the clarification. If that is the case and the paths are already cleaned, then would it be possible to entertain either removing |
We could change it for Go 2 but it seems fairly minor to me. To me it seems clearly desirable that the root be the same string passed to |
I hear you |
What version of Go are you using (
go version
)?go1.9.2
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?darwin/amd64
macOS 10.13 (17A405)
What did you do?
https://play.golang.org/p/ZqSxPfLasc
What did you expect to see?
Either:
Or:
What did you see instead?
Explanation
It appears that given a non-normalized path the
Walk()
function does not normalize a name of the first matching filesystem object, while the rest of the matches are being normalized. For extra fun, put the path in line 33 of the example to "./d/..//d/"As the documentation at https://golang.org/pkg/path/filepath/#Walk does not post a prerequisite for a normalized starting point, so I think it fair to consider inconsistent file names in callback a bug. Or that behavior should get documented.
The text was updated successfully, but these errors were encountered: