Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteBytes ¶ added in v0.101.0
WriteBytes atomically writes raw bytes to path using a unique temp file in the same directory + rename. A concurrent reader sees either the prior file (or ENOENT) or the new file in full — never a partially-written truncation. Two concurrent WriteBytes calls on the same path each get a distinct tmp via os.CreateTemp, so neither can clobber the other's tmp before rename — only the rename itself races, and the loser's content is still atomically visible to any reader that catches the file between the two renames.
perm applies after rename. CreateTemp opens with 0600; we Chmod before rename so the final inode lands with the requested perm regardless of the OS's umask handling.
func WriteJSON ¶
WriteJSON atomically writes data as indented JSON to path using a temp file + rename.
func WriteWith ¶ added in v0.103.0
WriteWith atomically writes to path by invoking write against a unique temp file in the same directory, then rename. It shares the temp+rename core with WriteBytes: the write callback streams the payload (avoiding a full in-memory buffer for large encoders), perm is applied via Chmod before rename, and any failure removes the temp file. See WriteBytes for the concurrency guarantees.
Types ¶
This section is empty.