atomicfile

package
v0.19.3 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package atomicfile is the one owner of stage-then-rename writes. The staging name must be unique per call: a fixed "<path>.tmp" let two concurrent savers of the same file truncate each other's staging copy, so half-written bytes could reach a credential document by rename (GDK-1233; GDK-1244 for the sites outside config). os.CreateTemp opens 0600 with O_EXCL — the mode every caller here wants — where os.WriteFile wrote through whatever already sat at the fixed name.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteFile

func WriteFile(path, pattern string, data []byte) error

WriteFile stages data through a unique temp file beside path (same directory, so the rename stays on one filesystem) and renames it into place. pattern names the temp file the way os.CreateTemp takes it, e.g. "config-*.json". On any failure before the rename the staging file is removed; after it, the remove is a no-op on a name that no longer exists.

Types

This section is empty.

Jump to

Keyboard shortcuts

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