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
Proposal: io/ioutil: add AppendFile function #30159
Comments
It's all but impossible to implement this correctly in the face of concurrency, making it unwise to offer to people who might expect it to work under those conditions. It needs operating-system-level semantics to work, and we don't have that. I am strongly against doing this. |
There are a lot of things in Go that need care when dealing with concurrency. Would not it be better just to report in the function comment that it needs locking? |
I believe @robpike meant concurrency within the entire operating system. That is, if another separate program is also tinkering with that file or directory. |
Wouldn't |
@Mottl no it wouldn't:
|
Is that a problem of Go language? My point of view is the same: report about file locking in godoc |
@Mottl no, it's what POSIX mandates, it has nothing to do with Go. As robpike says there's no real way to do this in a way that works reliably in the intuitive way. And that's before you consider the issue of portability. I'm not sure about what you mean by "report about file locking in godoc"... |
@CAFxX, I meant the same — it's not a Go problem. A comment about caution with file locking should be enough. |
If we add a function |
At some point we may want to move If and when that happens, Either way, I agree that this function does not belong in |
This is a proposal of adding
AppendFile
function toio.ioutil
.AppendFile
will act as WriteFile, except that it will not truncate a file if it already exists.Implementation: #30157
The text was updated successfully, but these errors were encountered: