atomic

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultFilePerm are the default file permission to use when the permissions
	// cannot be determined from the existing file.
	DefaultFilePerm os.FileMode = 0o644

	// DefaultFolderPerm is the default permission to use when creating parent
	// directories, if they do not already exist.
	DefaultFolderPerm os.FileMode = 0o755
)

Variables

This section is empty.

Functions

func Write

func Write(src, dst string, r io.Reader) error

AtomicWrite accepts a destination path and an reader. It copies the contents to a TempFile on disk, returning if any errors occur.

If the parent destination directory does not exist, it will be created automatically with permissions 0755. To use a different permission, create the directory first or use `chmod`.

If the destination path exists, all attempts will be made to preserve the existing file permissions. If those permissions cannot be read, an error is returned. If the file does not exist, it will be created automatically with permissions 0644. To use a different permission, create the destination file first.

If no errors occur, the Tempfile is "renamed" (moved) to the destination path. On Unix systems, this is guaranteed to be atomic. On Windows, it will be atomic if the files are on the same volume, but cannot be guaranteed if the file crosses volumes. For more information, see:

https://github.com/golang/go/issues/22397#issuecomment-498856679

Types

This section is empty.

Jump to

Keyboard shortcuts

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