atomicfile

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package atomicfile writes a file atomically: data is written to a temp file in the same directory, fsync'd, then renamed over the destination. A crash or full disk mid-write therefore leaves the previous file intact rather than a truncated one (production audit M3). Stdlib only.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Write

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

Write atomically writes data to path with the given permissions. The temp file is created in path's directory (so the final rename is on the same filesystem and is atomic), fsync'd, then renamed over path. On any failure the temp file is removed and path is left untouched.

Types

This section is empty.

Jump to

Keyboard shortcuts

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