atomicfile

package
v0.0.0-...-cae741c Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package atomicfile writes files atomically via temp file + rename.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteFile

func WriteFile(name string, data []byte, mode os.FileMode) error

WriteFile writes data to path using a temporary file in the same directory then renaming into place. Parent directories are created as needed. mode is applied to the final file (default 0o644 if zero).

Prefer WriteFileRoot for paths under a sync tree; this helper is for absolute paths outside an os.Root (for example the index under StateDir).

func WriteFileRoot

func WriteFileRoot(root *os.Root, name string, data []byte, mode os.FileMode) error

WriteFileRoot writes data to a path relative to root using a temporary file in the same directory then renaming into place. Parent directories are created under root as needed. mode is applied to the final file (default 0o644 if zero).

name must be relative to root (slash-separated is preferred). All I/O goes through root so path components and symlinks cannot escape the root tree. name is validated with fs.ValidPath and filepath.IsLocal before any I/O.

Types

This section is empty.

Jump to

Keyboard shortcuts

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