Skip to content
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: IsNotExist returns false for file on non-existing \\server\share #12374

Closed
alexbrainman opened this issue Aug 28, 2015 · 5 comments
Closed

os: IsNotExist returns false for file on non-existing \\server\share #12374

alexbrainman opened this issue Aug 28, 2015 · 5 comments

Comments

@alexbrainman
Copy link
Member

@alexbrainman alexbrainman commented Aug 28, 2015

This program

package main

import (
"log"
"os"
)

func main() {
_, err := os.Stat(\\no_such_server\no_such_share\no_such_file)
if err == nil {
log.Fatal("stat succeeded")
}
if !os.IsNotExist(err) {
log.Fatal("os.IsNotExist is false")
}
}

fails with

2015/08/28 10:08:21 os.IsNotExist is false
exit status 1

but should succeed.

It appears windows returns ERROR_BAD_NETPATH error here, but os.IsNotExist does not check for that error.

Alex

@alexbrainman alexbrainman added this to the Go1.6 milestone Aug 28, 2015
@choleraehyq

This comment has been minimized.

Copy link
Contributor

@choleraehyq choleraehyq commented Aug 28, 2015

I can't reproduce this problem on windows 7 amd64 with go1.5 .
Can you give an example path rather than \\no_such_server\no_such_share\no_such_file?Thx.

@alexbrainman

This comment has been minimized.

Copy link
Member Author

@alexbrainman alexbrainman commented Aug 28, 2015

If you run program above (as is), what does it output?

Alex

@choleraehyq

This comment has been minimized.

Copy link
Contributor

@choleraehyq choleraehyq commented Aug 28, 2015

The error is not ERROR_BAD_NETPATH. It's GetFileAttributesEx.

@alexbrainman

This comment has been minimized.

Copy link
Member Author

@alexbrainman alexbrainman commented Aug 28, 2015

@choleraehyq I am not asking what the error is, I just want to know what you see on your screen. My program outputs this:

2015/08/28 10:08:21 os.IsNotExist is false
exit status 1

Do you see something completely different? Would you mind providing your screen output? you can use mouse to select required portion of your screen and clipboard to capture it. Alternatively you can press PrintScreen key to get a picture.

Alex

@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Sep 15, 2015

CL https://golang.org/cl/14579 mentions this issue.

@golang golang locked and limited conversation to collaborators Sep 23, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.