I was quite surprised recently that, at least on linux, file.Close() does 
not guarantee file.Sync(); in some edge-cases, files can be not put 
properly to filesystem.

If the data integrity is critical, it seems better to call file.Sync() 
before file.Close().

(Linux has this in close / fsync syscall manpages.)

I am surprised that the docs don't mention this; also, that os.WriteFile 
does not call file sync, so even when os.WriteFile() returns no error, it 
doesn't mean the file is actually written on the disk!

I have 2 questions

1) should this be documented in godoc somewhere?
2) should os.WriteFile explicitly call fsync?


-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/dd574b31-8146-4710-9937-a56e8ecbe428n%40googlegroups.com.

Reply via email to