atomicfile

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package atomicfile replaces files so a reader, or the next run after a crash, sees either the old content or the new, never a mix.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Write

func Write(path string, data []byte) error

Write replaces path with data through a temporary file in the same directory, synced before the rename. A replaced file keeps its permission bits; a new one gets the mode os.Create gives it, under the umask. A symlink at path itself is replaced, never written through, and its replacement is no more open than the file it pointed at, when that file exists. Symlinks among path's parent directories are followed as usual. The directory must exist. The temporary file is hidden and ends in .tmp, so a reader that lists the directory by the target's extension skips one a killed run left behind, and the next Write of path removes it.

Types

This section is empty.

Jump to

Keyboard shortcuts

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