pathutil

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

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

View Source
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

func Inside(root, candidate string) bool

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

func Resolve(candidate string) (string, error)

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.

Jump to

Keyboard shortcuts

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