-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: file current cursor is 0 when open file as append mode with exist file(size>0) #12710
Comments
Which operating system do you see this on? I assume some Unix variant? It's quite likely that this behavior is platform-specific. Linux man pages say:
Go's docs merely say:
Perhaps we're missing some words somewhere. We should also verify that Unix, Windows, and Plan 9 are consistent. |
system: windows 7 64bit, go 1.5.1 amd64 |
I ran an experiment in https://go-review.googlesource.com/14807 Unix and Windows return 0 for the seek position on an O_APPEND file. Plan 9 returns the actual value. I imagine we should change Plan 9 to match the behavior of the popular platforms. (cc @0intro) And I guess we should just document the behavior on Unix and Windows. (cc @robpike) |
I'd document that calling Seek on a file opened with O_APPEND
is unspecified.
(I.e. you shouldn't call seek and even if the returned value is
non-zero, it's a race condition.)
|
@minux, SGTM. It's only a race if you ever called Write, right? But we can just say it's unspecified and leave it at that. |
CL https://golang.org/cl/14881 mentions this issue. |
cursor position should be size of "aaa.dat", but it's 0.
The text was updated successfully, but these errors were encountered: