atomicfile

package
v0.3.11 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 5 Imported by: 6 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 whole and durably: the content goes to a uniquely named temporary file beside the target, which is synced and renamed over it, and then the directory is synced so the rename survives a crash. A reader sees the old file or the new one and never a partial write, and concurrent writers never share a temporary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Write

func Write(path string, perm os.FileMode, write func(io.Writer) error) error

Write replaces path with what write produces, with permissions perm. On a failure before the rename path is untouched and the temporary is removed; a failure to sync the directory after it is reported with path already replaced.

func WriteFile

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

WriteFile replaces path with data, as os.WriteFile but atomically.

func WriteSeekable

func WriteSeekable(path string, perm os.FileMode, write func(io.WriteSeeker) error) error

WriteSeekable is Write for a producer that seeks back over what it wrote, as a muxer patching its header does: write is handed the temporary itself, unbuffered.

Types

This section is empty.

Jump to

Keyboard shortcuts

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