I made a simple library for personal use awhile ago ( https://github.com/rboyer/safeio) that tries to sequence posix atomic operations and fsync operations on file and directories for those times when you just need:
1. create temp file 2. write to temp file 3. fsync and close temp file 4. rename temp file to final destination name 5. fsync parent directory inode This library is to be used sparingly, because as other folks have pointed out, sometimes the kernel knows best (but sometimes it doesn't). On Friday, July 22, 2016 at 9:04:28 AM UTC-5, Ian Lance Taylor wrote: > > On Fri, Jul 22, 2016 at 3:40 AM, Manlio Perillo > <manlio....@gmail.com <javascript:>> wrote: > > > > I think your reasoning is wrong. > > WriteFile is a "self contained" function; it does not return the handle > to > > the file, so it can not be used inside a transaction. > > I really don't see valid reasons to not call Sync. > > WriteFile is a convenience function that can be broken down into a > series of steps. Sync is a special purpose operation. Normal file > I/O does not call Sync at any point. It would be very surprising if > WriteFile called Sync. If you want to do an operation like WriteFile > and call Sync, then break it down to the component steps yourself, > rather than using WriteFile, and call Sync yourself. > > Ian > -- 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. For more options, visit https://groups.google.com/d/optout.