atomicfile

package
v0.0.2 Latest Latest
Warning

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

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

Documentation

Overview

Package atomicfile writes a file durably. Content is written to a temp file in the destination directory, then renamed into place, so a concurrent reader never observes a partial file. Parent directories are created and the temp file is removed on any error. It consolidates several hand-rolled copies (task state, team graph, history + session stores) that had diverged — two of them used a non-atomic WriteFile+Rename that leaked a stray .tmp on a crash between write and rename.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Write

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

Write atomically writes data to path with the given file mode, creating parent directories (0o755) as needed. A concurrent reader sees either the old file or the new one, never a partial write; the temp file is cleaned up on any error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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