Documentation
¶
Overview ¶
Package atomicfile writes files atomically: content is written to a temporary file in the same directory as the destination, then renamed into place. A write that fails partway through (a full disk, a killed process, a crash) leaves the temp file incomplete but never touches the destination, so a good previous artifact is never truncated or corrupted by a failed overwrite — os.Create alone truncates the destination immediately, before a single byte of the new content is written.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Write ¶
Write creates parent directories for path as needed, calls write with a temporary file in the same directory, and renames it into place at path only if write and the subsequent close both succeed. perm sets the final file's permissions. A same-directory temp file guarantees the rename is on the same filesystem, so it's atomic.
Types ¶
This section is empty.