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

Comments

@alexbrainman
Copy link
Member

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
Copy link
Contributor

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
Copy link
Member Author

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

Alex

@choleraehyq
Copy link
Contributor

The error is not ERROR_BAD_NETPATH. It's GetFileAttributesEx.

@alexbrainman
Copy link
Member Author

@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
Copy link

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
Development

No branches or pull requests

3 participants