Help us shape the future of Go! Take the 2026 Go Developer Survey

cwdpath

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package cwdpath confines paths to the working directory (--cwd).

TinyAgent reads and writes its project state only inside --cwd. Resolve turns a path from config or the environment into one inside cwd, or refuses it: a path that leaves cwd through "..", an absolute path elsewhere, or a symlink that resolves outside cwd. Only cwd itself and the path below it are looked at.

Index

Constants

This section is empty.

Variables

View Source
var ErrOutside = errors.New("path must stay inside --cwd")

ErrOutside marks a path that was refused because it would leave --cwd.

Functions

func Resolve

func Resolve(cwd, p string) (string, error)

Resolve returns p (relative to cwd, or absolute) as an absolute path inside cwd. It refuses, wrapping ErrOutside, a path with a ".." element, an absolute path outside cwd, cwd itself, and one whose existing part resolves through a symlink to somewhere outside cwd. The path need not exist. The returned path keeps cwd as given (made absolute).

func Within

func Within(path, dir string) bool

Within reports whether path is dir or below it (lexically).

Types

This section is empty.

Jump to

Keyboard shortcuts

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