fsx

package
v1.31.1 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 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

View Source
const SharedFile = "AGENTS.md"

SharedFile is the one core file a host project may already have: AGENTS.md is an open convention other tools write too. GTT never takes it over and never refuses to install because of it (Canon 3.0 §28): it keeps its contract inside a delimited block of the host's file and touches only that block - on install, update, clean, export and rollback alike.

Variables

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

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

Functions

func BlockHash added in v1.8.0

func BlockHash(path string) (string, bool)

BlockHash is the hash of GTT's block in a shared file, comparable with the ledger's hash of the package file; ok is false when the file has no block.

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 HostText added in v1.8.0

func HostText(path string) (string, bool)

HostText is the file without GTT's block, and whether anything of the host remains (false: the file is entirely GTT's and may be removed whole).

func IsShared added in v1.8.0

func IsShared(rel string) bool

IsShared reports whether a core path is the shared instruction file.

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 Merge added in v1.8.0

func Merge(hostText, gttText string) string

Merge places GTT's contract in the host's file as one delimited block, replacing a previous block and keeping every host line.

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 StripOrRemove added in v1.8.0

func StripOrRemove(path string) error

StripOrRemove takes GTT out of a shared file: the block goes, the host's lines stay; a file that is only GTT's contract is removed. A file with no GTT block that is not GTT's contract is the host's alone and is left as is (an init interrupted before the merge must not cost the host its file).

func WriteJSON

func WriteJSON(path string, v any) error

WriteJSON writes v atomically as indented JSON.

func WriteMerged added in v1.8.0

func WriteMerged(path, gttText string) error

WriteMerged writes GTT's contract into the host's existing file.

Types

This section is empty.

Jump to

Keyboard shortcuts

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