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: clarify documentation for O_TRUNC #28699

bcmills opened this Issue Nov 9, 2018 · 3 comments


None yet
3 participants
Copy link

bcmills commented Nov 9, 2018

The comment for os.O_TRUNC currently says:

O_TRUNC int = syscall.O_TRUNC // if possible, truncate file when opened.

The “if possible” part of that comment is ambiguous: on Linux it seems to mean “if the file is a regular file or symlink to a regular file” (i.e., not a stream like /dev/stdout), but it could be “impossible” to truncate the file for other reasons (such as a permission error), and os.OpenFile with os.O_TRUNC seems to report an error in those cases.

We should drop the “if possible” phrase and instead explicitly document the conditions under which O_TRUNC is ignored.

@bcmills bcmills added this to the Go1.12 milestone Nov 9, 2018


This comment has been minimized.

Copy link
Member Author

bcmills commented Nov 9, 2018


This comment has been minimized.

Copy link

robpike commented Nov 10, 2018

I fear that making the os package document every aspect, for every OS, of the calls it wraps is a Sisyphean endeavor and not worth pursuing.


This comment has been minimized.

Copy link

gopherbot commented Dec 20, 2018

Change mentions this issue: os: clarify O_TRUNC comment

@gopherbot gopherbot closed this in 745273f Dec 20, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.