Documentation ¶
Overview ¶
Package safeio implements convenient I/O routines that provide additional levels of safety in the presence of unexpected failures.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteFile ¶
WriteFile writes data to a file named by filename, atomically.
It's a wrapper to os.WriteFile, but provides atomicity (and increased safety) by writing to a temporary file and renaming it at the end.
Before the final rename, the given ops (if any) are called. They can be used to manipulate the file before it is atomically renamed. If any operation fails, the file is removed and the error is returned.
Note this relies on same-directory Rename being atomic, which holds in most reasonably modern filesystems.
Types ¶
Click to show internal directories.
Click to hide internal directories.