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

Open
bcmills opened this Issue Nov 9, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@bcmills
Member

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

@bcmills

This comment has been minimized.

Member

bcmills commented Nov 9, 2018

@robpike

This comment has been minimized.

Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment