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: Inconsistent EOF error message returned by File.ReadAt on windows #5619

Closed
syndtr opened this issue Jun 3, 2013 · 6 comments
Closed

Comments

@syndtr
Copy link

syndtr commented Jun 3, 2013

What steps will reproduce the problem?
1. create file.tmp file
2. run this http://play.golang.org/p/jZkzWF8Npr
3.

What is the expected output?
io.EOF

What do you see instead?
read file.tmp: Reached the end of the file.

Which compiler are you using (5g, 6g, 8g, gccgo)?
6g

Which operating system are you using?
windows 8 64-bit

Which version are you using?  (run 'go version')
go version go1.1rc3 windows/amd64
@peterGo
Copy link
Contributor

peterGo commented Jun 3, 2013

Comment 1:

The error message text is OS dependent. The important fact is that, on Windows, io.EOF
is not returned.
package main
import (
    "fmt"
    "io"
    "os"
)
func main() {
    f, err := os.Create("5619.tmp")
    if err != nil {
        fmt.Println(err)
        return
    }
    buf := make([]byte, 10)
    n, err := f.ReadAt(buf, 0)
    fmt.Println(n, err == io.EOF, err)
}
Output:
Linux:
0 true EOF
Windows:
0 false read 5619.tmp: Reached the end of the file.

Attachments:

  1. 5619.go (333 bytes)

@syndtr
Copy link
Author

syndtr commented Jun 4, 2013

Comment 2:

Yes, you're right the error returned should be equal with io.EOF. Otherwise, it would be
hard to detect an EOF.

@alexbrainman
Copy link
Member

Comment 3:

Here is a fix proposal https://golang.org/cl/9952044/.
Alex

Labels changed: added os-windows, packagebug.

Owner changed to @alexbrainman.

Status changed to Started.

@alexbrainman
Copy link
Member

Comment 4:

This issue was closed by revision bb6e265.

Status changed to Fixed.

@bradfitz
Copy link
Contributor

Comment 5:

Issue #6277 has been merged into this issue.

@alexbrainman
Copy link
Member

Comment 6:

Issue #6277 has been merged into this issue.

This issue was closed.
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

5 participants