fileutil

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AtomicWriteFile added in v0.2.0

func AtomicWriteFile(dest string, data []byte, perm os.FileMode) error

AtomicWriteFile writes data to dest atomically: it writes to a temp file in the same directory, applies perm, then renames onto dest via ReplaceFile. The temp file is removed on every error path. Use for files that other processes or goroutines may read concurrently (config, caches).

func ReplaceFile

func ReplaceFile(tmp, dest string) error

ReplaceFile renames tmp onto dest, falling back to a copy when the rename fails — Windows encryption-software filter drivers report a cross-device link (EXDEV) for a same-dir rename. The rename error surfaces only if the copy also fails.

Types

This section is empty.

Directories

Path Synopsis
Package encoding detects and converts file encodings for the built-in file tools.
Package encoding detects and converts file encodings for the built-in file tools.

Jump to

Keyboard shortcuts

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