atomicfile: github.com/facebookgo/atomicfile Index | Files

package atomicfile

import "github.com/facebookgo/atomicfile"

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

Package Files

atomicfile.go

type File Uses

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 Uses

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 Uses

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 Uses

func (f *File) Close() error

Close the file replacing the configured file.

Package atomicfile imports 3 packages (graph) and is imported by 11 packages. Updated 2017-07-26. Refresh now. Tools for package owners.