Documentation
¶
Overview ¶
Package fileutil provides file system utilities including atomic write operations.
Index ¶
- func AtomicWriteFile(path string, data []byte, perm os.FileMode) error
- func AtomicWriteJSON(path string, v any) error
- func AtomicWriteJSONWithPerm(path string, v any, perm os.FileMode) error
- func AtomicWriteYAML(path string, v any) (err error)
- func AtomicWriteYAMLWithPerm(path string, v any, perm os.FileMode) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AtomicWriteFile ¶
AtomicWriteFile writes data to a file atomically using a temp file + rename pattern. This ensures interrupted writes leave the original file intact.
The caller is responsible for ensuring the parent directory exists. Permissions are applied to the final file via the perm parameter.
func AtomicWriteJSON ¶
AtomicWriteJSON writes v as indented JSON to path atomically. Uses 2-space indentation and appends a trailing newline for POSIX compliance.
The caller is responsible for ensuring the parent directory exists. The file is created with 0644 permissions.
func AtomicWriteJSONWithPerm ¶
AtomicWriteJSON writes v as indented JSON to path atomically with specified permissions. Uses 2-space indentation and appends a trailing newline for POSIX compliance.
The caller is responsible for ensuring the parent directory exists.
func AtomicWriteYAML ¶
AtomicWriteYAML writes v as YAML to path atomically. Appends a trailing newline for POSIX compliance.
The caller is responsible for ensuring the parent directory exists. The file is created with 0644 permissions.
func AtomicWriteYAMLWithPerm ¶
AtomicWriteYAMLWithPerm writes v as YAML to path atomically with specified permissions. Appends a trailing newline for POSIX compliance.
The caller is responsible for ensuring the parent directory exists.
Types ¶
This section is empty.