-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
os: ReadFile on directories does not return EISDIR in windows #43322
Comments
Internally it ends up doing code that is equivalent to:
Which does return the invalid handle error. |
I believe it should be fixed. Opening a directory in read/write mode does produce the correct error because there is a special handling for it: Line 177 in 4d27c4c
What's missing is returning of the same error when a |
Change https://golang.org/cl/279852 mentions this issue: |
Change https://golang.org/cl/374394 mentions this issue: |
@dop251 I am not convinced. Where is it documented that Thank you. Alex |
To clarify, it applies not just to
|
I don't see how that is relevant to
Anyway I am still unconvinced we should change current implementation just so we return Alex |
The fact there is a cross-platform As for documentation, neither does it say that opening a directory in read/write mode should return In any case I agree it's not clear-cut and you can argue either way. The change is also breaking (if there is a Windows-specific code somewhere that expects ERROR_INVALID_HANDLE in this situation it will break). I still think this is a reasonable change. The question is who makes the decision? |
Why would we do that? What is the benefit?
Indeed it does. And we would have to add more code and comments explaining the reason why the code is written that way. I don't think this is all worth to just please you.
I don't know. Sorry. Alex |
The benefit is obvious: less platform-specific code required. For example take the original issue that was the reason for me to open this: dop251/goja_nodejs#21. As it stands now, I have to add some Windows-specific code to handle the situation. If |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
https://play.golang.org/p/GwvDhx3PqK-
What did you expect to see?
All good
What did you see instead?
Unexpected error: read /: The handle is invalid
The text was updated successfully, but these errors were encountered: