atomicfile

package module
Version: v0.0.0-...-2de1f20 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2015 License: BSD-3-Clause Imports: 3 Imported by: 33

README

atomicfile Build Status

Documentation: https://godoc.org/github.com/facebookgo/atomicfile

NOTE: This package uses os.Rename, which may or may not be atomic on your operating system. It is known to not be atomic on Windows. https://github.com/natefinch/atomic provides a similar library that is atomic on Windows as well and may be worth investigating.

Documentation

Overview

Package atomicfile provides the ability to write a file with an eventual rename on Close (using os.Rename). This allows for a file to always be in a consistent state and never represent an in-progress write.

NOTE: `os.Rename` may not be atomic on your operating system.

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 behaves like os.File, but does an atomic rename operation at Close.

func New

func New(path string, mode os.FileMode) (*File, error)

New creates a new temporary file that will replace the file at the given path when Closed.

func (*File) Abort

func (f *File) Abort() error

Abort closes the file and removes it instead of replacing the configured file. This is useful if after starting to write to the file you decide you don't want it anymore.

func (*File) Close

func (f *File) Close() error

Close the file replacing the configured file.

Source Files

Jump to

Keyboard shortcuts

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