atomicfile

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 5 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 writes files so that readers never observe a partial or mixed state.

It exists because two packages (config, endpoint) need the same write-temp-then-rename discipline, and because the rename step needs a platform-specific retry that neither should have to remember.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteFile

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

WriteFile writes data to path atomically: the bytes go to a temporary file in the same directory, are flushed, and the temporary file is then renamed over the destination.

perm is applied to the temporary file before the rename, so the destination never exists with wider permissions. On Windows the mode has no effect (ACLs govern access there).

The parent directory is created when missing.

Types

This section is empty.

Jump to

Keyboard shortcuts

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