Documentation
¶
Overview ¶
Package atomicfile provides atomic file writes via temp-file + rename.
Writes land in a temporary file in the same directory as the target, are fsynced, then atomically renamed into place. Readers never see a partial or truncated file — only the previous complete version or the new complete version.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer is an io.WriteCloser that writes to a temporary file and atomically renames it to the target path on Close. Call Abort to discard the temp file without touching the target.
func Create ¶
Create returns a Writer that will atomically replace path on Close. The temp file is created in the same directory as path to guarantee same-filesystem rename semantics.
func (*Writer) Abort ¶
Abort discards the temp file without renaming. The target is untouched. Safe to call multiple times or after Close.