Documentation
¶
Overview ¶
Package atomicfile replaces a file atomically. It is the one implementation behind fsx.WriteFile and secret.WriteFile, which word its errors each in their own way.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrSymlink = errors.New("is a symbolic link")
ErrSymlink reports a symbolic link at the path to write.
Functions ¶
func Write ¶
Write writes data to path through a temporary file in the same directory, named after pattern as os.CreateTemp reads it, and renames it into place, so a reader sees the old contents or the new ones, never part of either. The temporary file gets mode perm before any data reaches it; outside Windows a failure to set it is an error, on Windows it is ignored, since only the read-only bit can be set there. The data is synced to disk before the rename.
The directory must exist. A symbolic link at path is refused with ErrSymlink. Errors are returned as the os package returns them; the caller adds the path and its prefix.
Types ¶
This section is empty.