Documentation
¶
Overview ¶
Package pathutil contains small, dependency-free path helpers shared across aiwf packages. The helpers are designed to fail closed: when input is unusable (relative paths, empty strings, broken symlinks), they return false / an error rather than guessing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotAbsolute = errors.New("path must be absolute")
ErrNotAbsolute is returned by Resolve when its input is a relative path. Callers are expected to make paths absolute before calling Resolve (typically via filepath.Join with an absolute repo root).
Functions ¶
func Inside ¶
Inside reports whether candidate, after cleaning, lies at or under root. Both paths must be absolute; relative inputs return false.
The check appends a path separator to root before prefix-matching so that "/repo" does not match "/repository". Paths equal to root are considered inside.
func Resolve ¶
Resolve returns candidate with symlinks evaluated and the result cleaned. candidate must be absolute; relative inputs return ErrNotAbsolute so callers fail closed instead of silently joining against an unrelated working directory.
If the path does not exist, Resolve returns the cleaned absolute form (lexical fallback) and a nil error so callers can still report a clean "missing" finding rather than crashing.
Broken symlinks and symlink loops produce errors — they are treated as "unresolvable" so callers fail closed.
Types ¶
This section is empty.