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

os: Inconsistent EOF error message returned by File.ReadAt on windows #5619

syndtr opened this issue Jun 3, 2013 · 6 comments

Comments

@syndtr
Copy link

@syndtr 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

This comment has been minimized.

Copy link
Contributor

@peterGo 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

This comment has been minimized.

Copy link
Author

@syndtr 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

This comment has been minimized.

Copy link
Member

@alexbrainman alexbrainman commented Jun 7, 2013

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

This comment has been minimized.

Copy link
Member

@alexbrainman alexbrainman commented Jun 10, 2013

Comment 4:

This issue was closed by revision bb6e265.

Status changed to Fixed.

@bradfitz

This comment has been minimized.

Copy link
Contributor

@bradfitz bradfitz commented Aug 29, 2013

Comment 5:

Issue #6277 has been merged into this issue.

@alexbrainman

This comment has been minimized.

Copy link
Member

@alexbrainman alexbrainman commented Aug 29, 2013

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
Linked pull requests

Successfully merging a pull request may close this issue.

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