fsatomic

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package fsatomic writes files so a reader never observes a partial file and a crash cannot lose the previous contents: write to a sibling temp file, fsync it, rename over the destination, then fsync the directory so the rename itself is durable. The rename-only idiom used before this package left a window where the data sat in the page cache with no durability at all.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteFile

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

WriteFile atomically replaces path with data at the given permissions. The temp file is created in the destination directory (rename is only atomic within one filesystem) with owner-only access, then chmodded to perm before the rename, so the final mode never appears with looser intermediate access. On any failure the temp file is removed and the previous contents of path are untouched.

Types

This section is empty.

Jump to

Keyboard shortcuts

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