Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileWriter ¶
type FileWriter struct {
// contains filtered or unexported fields
}
FileWriter is a thread safe writer that does an atomic write to the target file. It allows one writer at a time to acquire a lock, write the file, and atomically replace the contents of the target file.
func CreateFileWriter ¶
func CreateFileWriter(ctx context.Context, path string) (*FileWriter, error)
CreateFileWriter takes path as an absolute path of the target file and creates a new FileWriter by attempting to create a tempfile
func (*FileWriter) Commit ¶
func (fw *FileWriter) Commit() error
Commit will close the temporary file and rename it to the target file name the first call to Commit() will close and delete the temporary file, so subsequenty calls to Commit() are gauaranteed to return an error.
Click to show internal directories.
Click to hide internal directories.