Help us shape the future of Go! Take the 2026 Go Developer Survey

atomicfile

package
v0.60.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package atomicfile replaces files so a reader never sees a partial write.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Write

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

Write replaces path with data and perm. It writes a temporary file in the same directory, syncs it, and renames it over path, so a crash leaves either the old file or the new one. The parent directory must exist.

perm is the exact mode of the new file. The umask does not narrow it, as it would for os.WriteFile.

The temporary file is hidden and ends in .tmp, so a directory watcher that skips dotfiles or matches on extension never loads it.

Types

This section is empty.

Jump to

Keyboard shortcuts

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