Documentation ¶
Overview ¶
Package files contains file-related utilities.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultDataDir ¶ added in v0.1.4
DefaultDataDir returns the default directory for Service Weaver files: $XDG_DATA_HOME/serviceweaver, or ~/.local/share/serviceweaver if XDG_DATA_HOME is not set.
Types ¶
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer writes a sequence of bytes to a file. In case of errors, the old file contents remain untouched since the writes are applied atomically when the Writer is closed.
func NewWriter ¶
NewWriter returns a writer that writes to the named files.
The caller should eventually call Cleanup. A recommended pattern is:
w := files.NewWriter(dst) defer w.Cleanup() ... write to w ... err := w.Close()
func (*Writer) Cleanup ¶
func (w *Writer) Cleanup()
Cleanup releases any resources in use by the writer, without attempting to write collected bytes to the destination. It is safe to call Cleanup() even if Close or Cleanup have already been called.