atomicfile

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package atomicfile writes files atomically. Content goes to a temporary file in the target directory, which replaces the target on Commit.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	*os.File
	// contains filtered or unexported fields
}

File is a temporary file that replaces the file at its target path when committed.

func Create

func Create(path string, perm os.FileMode) (*File, error)

Create creates a temporary file next to path. Call Commit to move it into place. Close without Commit removes the temporary file, so a deferred Close cleans up on error.

func (*File) Close

func (f *File) Close() error

Close discards the temporary file, unless it has been committed.

func (*File) Commit

func (f *File) Commit() error

Commit flushes the file to disk, closes it and renames it to the target path.

Jump to

Keyboard shortcuts

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