-
Notifications
You must be signed in to change notification settings - Fork 18k
os: Stat does not return error when path separators are added to end of an existing file path #33578
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
Edit: Following is in response to suggestion (now removed) by other user that provided this URL: http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap03.html#tag_03_266 Interesting. It's inconsistent with how Linux and MacOS work though:
Unless the OS' |
On GNU/Linux I get an error If you don't see this on macOS then I think macOS must work differently. Try writing the equivalent C program and see what happens. |
Equivalent C program shows consistent result for both Linux and MacOS, i.e. if I add a trailing slash to the end of an existing file path when calling stat, it fails to stat the file.
On MacOS and Linux, when run in the same directory as a file called 'hello.txt', it returns: |
What version of MacOS are you using? I can't reproduce the issue with go 1.12.9 and Mac OS 10.14.6:
|
/me can not reproduce with Mac OS 10.14.6, go 1.12.8, 1.12.9 and tip. |
Original test carried out on MacOS 10.15 Beta with 1.12.7.
Homebrew formula for 1.12.7 now missing, so unable to check if it was that specific build/env setup. |
Try this:
|
Thanks for the instructions @gregory-m. |
@jonhadfield Thank you for fast response. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
Only tried on MacOS and Go Playground.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Used os.Stat against a path that doesn't exist. The path was constructed by adding "/" to the end of a valid file path.
https://play.golang.org/p/6J4uiEC-UsG
You can add many trailing slashes and it still returns without error:
https://play.golang.org/p/gP_NBuzG74B
What did you expect to see?
Error to be:
stat <path>: No such file or directory
What did you see instead?
Error:
<nil>
The text was updated successfully, but these errors were encountered: