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: Create does not return error on filename with colon(:) on Windows #13035

Closed
tpng opened this issue Oct 23, 2015 · 3 comments
Closed

os: Create does not return error on filename with colon(:) on Windows #13035

tpng opened this issue Oct 23, 2015 · 3 comments

Comments

@tpng
Copy link

tpng commented Oct 23, 2015

What version of Go are you using (go version)?
go version go1.5.1 windows/386

What operating system and processor architecture are you using?
Windows 7 64-bit

What did you do?

package main

import (
    "log"
    "os"
)

func main() {
    f, err := os.Create("test:.txt")
    if err != nil {
        log.Fatal(err)
    }
    defer f.Close()
    if _, err := f.Write([]byte("testing")); err != nil {
        log.Fatal(err)
    }
}

Sorry for not using playground, still got 403 in Hong Kong.

What did you expect to see?
: is invalid character for file name on Windows.
Expected error on os.Create or f.Write.

What did you see instead?
An empty file named test is created after running the program, without any errors returned.

@davecheney
Copy link
Contributor

I think what you are seeing is NTFS alternative files streams, you've created a file called test, and in the alternative stream the sting "testing" is written.

I think windows explorer doesn't show this properly, but should be able to reopen the same file you created and check for the contents.

http://blogs.technet.com/b/askcore/archive/2013/03/24/alternate-data-streams-in-ntfs.aspx

On 23 Oct 2015, at 20:43, Benny Ng notifications@github.com wrote:

What version of Go are you using (go version)?
go version go1.5.1 windows/386

What operating system and processor architecture are you using?
Windows 7 64-bit

What did you do?

package main

import (
"log"
"os"
)

func main() {
f, err := os.Create("test:.txt")
if err != nil {
log.Fatal(err)
}
defer f.Close()
if _, err := f.Write([]byte("testing")); err != nil {
log.Fatal(err)
}
}
Sorry for not using playground, still got 403 in Hong Kong.

What did you expect to see?
: is invalid character for file name on Windows.
Expected error on os.Create or f.Write.

What did you see instead?
An empty file named test is created after running the program, without any errors returned.


Reply to this email directly or view it on GitHub.

@tpng
Copy link
Author

tpng commented Oct 23, 2015

Wow, that's just eye opening, thanks so much for the response.

By opening the file using the same file name, I can read back the same content.

Since it's a platform-specific feature instead, I will close the issue.
Please feel free to reopen if there's something we can do, thanks again!

@tpng tpng closed this as completed Oct 23, 2015
@davecheney
Copy link
Contributor

I think we'll have to chalk this up to a feature :)

It's only available on Windows, using NTFS.

On 23 Oct 2015, at 22:31, Benny Ng notifications@github.com wrote:

Wow, that's just eye opening, thanks so much for the response.

By opening the file using the same file name, I can read back the same content.

Since it's a platform-specific feature instead, I will close the issue.
Please feel free to reopen if there's something we can do, thanks again!


Reply to this email directly or view it on GitHub.

@tpng tpng changed the title os: Create does not return error on invalid filename on Windows os: Create does not return error on filename with colon(:) on Windows Oct 26, 2015
@golang golang locked and limited conversation to collaborators Oct 26, 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