-
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
io/ioutil: document that WriteFile does not do a f.Sync #20599
Comments
Out of curiosity, why? In general, if you're writing to a file, you want to check for an |
@mvdan Closing a file doesn't issue a sync. At the same time, there are plenty of files for which you won't care, and syncing unnecessarily will incur a performance cost. Maybe this is a documentation issue and no change to the code should be made. |
My bad - I thought closing a file meant syncing it too, but I must have gotten confused. It's a bit bizarre that you could care about close errors but not about sync errors, though. |
Some discussion about While it may seem reasonable for This is indeed a documentation issue. |
We can document the lack of fsync for Go 1.10 unless somebody sends a change for Go 1.9 which would be fine too. |
That is an odd sort of documentation to write. There are all kinds of functions that do not call |
I would agree, but this keeps coming up, so it makes me wonder if my expectations are wrong. But I'm also fine not doing anything here again. |
Lots of things don't call sync. This is not one worth singling out. I say stet. |
Okay, fair enough. Closing. |
iouti.WriteFile function does not call os.File.Sync internally (golang/go#20599), so the code has been updated to forced a sync after each file written by an update
iouti.WriteFile function does not call os.File.Sync internally (golang/go#20599), so the code has been updated to forced a sync after each file written by an update
iouti.WriteFile function does not call os.File.Sync internally (golang/go#20599), so the code has been updated to forced a sync after each file written by an update
What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?What did you do?
Use ioutil.WriteFile.
What did you expect to see?
I'm sorry if the expectation is wrong but I expected the source of ioutil.WriteFile to have a call to
f.Sync()
What did you see instead?
No call to
f.Sync()
was made internallyIf fixing this is acceptable, I'll be glad to send a small patch 👍
The text was updated successfully, but these errors were encountered: