Documentation
¶
Overview ¶
Package fsx provides path safety, hashing and copy primitives.
Index ¶
- Variables
- func CopyFile(src, dst string, overwrite bool) error
- func DiffFiles(oldPath, newPath, oldLabel, newLabel string, limit int) string
- func Exists(path string) bool
- func HashFile(path string) (string, error)
- func HashTree(root string, files []string) (string, error)
- func ListFiles(root string) ([]string, error)
- func ReadJSON(path string, v any) error
- func SafeJoin(root, rel string) (string, error)
- func WriteJSON(path string, v any) error
Constants ¶
This section is empty.
Variables ¶
var IgnoredDirs = map[string]bool{".git": true, "__pycache__": true}
IgnoredDirs are never hashed, copied or exported as package content.
Functions ¶
func CopyFile ¶
CopyFile copies src to dst preserving the mode; it creates parent directories and refuses to overwrite unless overwrite is true.
func DiffFiles ¶ added in v1.1.0
DiffFiles returns a compact line diff from the file at oldPath to the file at newPath, in unified style with two lines of context and at most limit lines of output. Binary or very large files are summarized, not printed.
func HashTree ¶
HashTree returns one sha256 over the sorted (path, content hash) pairs of the given files under root.
func ListFiles ¶
ListFiles returns every regular file under root as slash-separated paths relative to root, sorted. Symlinks are reported through the error: a package or an export source containing one that escapes root is unsafe.
Types ¶
This section is empty.