fsx

package
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package fsx provides path safety, hashing and copy primitives.

Index

Constants

This section is empty.

Variables

View Source
var IgnoredDirs = map[string]bool{".git": true, "__pycache__": true}

IgnoredDirs are never hashed, copied or exported as package content.

Functions

func CopyFile

func CopyFile(src, dst string, overwrite bool) error

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

func DiffFiles(oldPath, newPath, oldLabel, newLabel string, limit int) string

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 Exists

func Exists(path string) bool

Exists reports whether a path exists (following nothing).

func HashFile

func HashFile(path string) (string, error)

HashFile returns the hex sha256 of a file.

func HashTree

func HashTree(root string, files []string) (string, error)

HashTree returns one sha256 over the sorted (path, content hash) pairs of the given files under root.

func ListFiles

func ListFiles(root string) ([]string, error)

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.

func ReadJSON

func ReadJSON(path string, v any) error

ReadJSON reads a JSON file into v; a missing file returns os.ErrNotExist.

func SafeJoin

func SafeJoin(root, rel string) (string, error)

SafeJoin joins rel under root and rejects absolute or rooted paths, traversal and any existing symlink component that resolves outside root.

func WriteJSON

func WriteJSON(path string, v any) error

WriteJSON writes v atomically as indented JSON.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL