replacefile

package
v1.0.0-beta.15 Latest Latest
Warning

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

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

Documentation

Overview

Package replacefile replaces a file with a temporary one written beside it, by renaming the temporary file over it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Rename

func Rename(tmp, dest string) error

Rename renames tmp over dest, which on Unix replaces dest atomically: a concurrent reader or writer never sees a partial or interleaved file. On Windows a rename over a file another process holds open without FILE_SHARE_DELETE fails, and Go's own os.Open does not share delete, so Rename retries a few times there and then returns the error, leaving dest untouched; rewriting it in place instead would bring back the interleaved writes the rename avoids. The caller removes tmp.

Types

This section is empty.

Jump to

Keyboard shortcuts

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