package standard library
Version: go1.16.8 Latest Latest

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

Go to latest
Published: Sep 9, 2021 License: BSD-3-Clause Imports: 8 Imported by: 0



Package renameio writes files atomically by renaming temporary files.



This section is empty.


This section is empty.


func Pattern

func Pattern(filename string) string

Pattern returns a glob pattern that matches the unrenamed temporary files created when writing to filename.

func ReadFile added in go1.13

func ReadFile(filename string) ([]byte, error)

ReadFile is like os.ReadFile, but on Windows retries spurious errors that may occur if the file is concurrently replaced.

Errors are classified heuristically and retries are bounded, so even this function may occasionally return a spurious error on Windows. If so, the error will likely wrap one of:

- internal/syscall/windows.ERROR_SHARING_VIOLATION

func WriteFile

func WriteFile(filename string, data []byte, perm fs.FileMode) (err error)

WriteFile is like os.WriteFile, but first writes data to an arbitrary file in the same directory as filename, then renames it atomically to the final name.

That ensures that the final location, if it exists, is always a complete file.

func WriteToFile

func WriteToFile(filename string, data io.Reader, perm fs.FileMode) (err error)

WriteToFile is a variant of WriteFile that accepts the data as an io.Reader instead of a slice.


This section is empty.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL