Documentation
¶
Overview ¶
Package fsutil provides crash-safe atomic file writes for sensitive on-disk state (keys, sessions, config). A write either lands in full or not at all, so a crash or full disk never leaves a partial file behind.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteFileAtomic ¶
WriteFileAtomic writes data to path atomically, replacing any existing file. It writes a temp file in the same directory, fsyncs it, and renames it over path. The parent directory is created with 0700 if absent.
func WriteFileExclusive ¶
WriteFileExclusive writes data to path atomically but fails with os.ErrExist if path already exists. Like WriteFileAtomic it never leaves a partial file; it hard-links the fully written temp file into place, so the create-or-fail decision is atomic against concurrent writers. Callers can match the already-exists case with errors.Is(err, os.ErrExist).
Types ¶
This section is empty.