-
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: ambiguous mode/perm documentation for Create and OpenFile #30400
Comments
It just occurred to me that os.MkdirAll might suffer from the same ambiguity, but I just checked and this is not the case. |
/cc @ianlancetaylor |
Change https://golang.org/cl/163744 mentions this issue: |
Cool, thanks! Commit 3995bc007d94f6923d79f3b18089dab2caaa4580 on googlesource.com contains two typos:
I can't seem to comment directly on that commit. |
One cannot comment directly on the googlesource site. Please feel free to comment on gerrit, which is our code review tool. Use this link - https://go-review.googlesource.com/c/go/+/163744/ |
Thanks, updated the CL with typo fixes. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Run this test program:
What did you expect to see?
The documentation for os.Create says:
This reads as if mode
0666
always applies.Likewise, the documentation for os.OpenFile says:
This might also lead one to expect that perm is applicable with, e. g., O_CREATE and O_TRUNC.
Hence, one would expect:
What did you see instead?
The actual behaviour is in line with the analogous flags for the
open()
function from the POSIX standard:The POSIX standard makes it explicitly clear that the mode remains unchanged when the file already exists:
I suggest the go documentation is likewise explicit. For example I would change the os.Create docs:
to:
and the os.OpenFile docs:
to
The text was updated successfully, but these errors were encountered: