atomicfile

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package atomicfile provides atomic file write primitives. The goal is that after a successful WriteFile call, readers either see the full new content or the full previous content — never a partial / truncated file caused by a crash, OS reboot, disk-full, or SIGKILL halfway through the write.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteFile

func WriteFile(path string, data []byte, perm fs.FileMode) (retErr error)

WriteFile atomically writes data to the file named by path. It writes to a temp file in the same directory (so the final rename is atomic on the same filesystem), fsyncs the temp file, then renames it over path. On any error the temp file is removed.

perm is applied to the final file via chmod after creation; on Unix the resulting file ignores umask, matching os.WriteFile semantics.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL