path

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package path provides path resolution and normalization utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanonicaliseRoot

func CanonicaliseRoot(fs FileSystem, root string) (string, error)

CanonicaliseRoot canonicalises a workspace root path by making it absolute and resolving symlinks. Returns an error if the path doesn't exist or isn't a directory.

Types

type FileSystem

type FileSystem interface {
	ValidateAbs(path string) (string, error)
	EvalSymlinks(path string) (string, error)
	Stat(path string) (os.FileInfo, error)
}

FileSystem abstracts filesystem operations for path resolution.

type OSFileSystem

type OSFileSystem struct{}

OSFileSystem implements FileSystem using the real OS.

func (OSFileSystem) EvalSymlinks(path string) (string, error)

EvalSymlinks returns the path after the evaluation of any symbolic links.

func (OSFileSystem) Stat

func (OSFileSystem) Stat(path string) (os.FileInfo, error)

Stat returns a FileInfo describing the named file.

func (OSFileSystem) ValidateAbs

func (OSFileSystem) ValidateAbs(path string) (string, error)

ValidateAbs returns the absolute representation of path.

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver provides path resolution within a workspace boundary.

func NewResolver

func NewResolver(workspaceRoot string) *Resolver

NewResolver creates a new path resolver for the given workspace.

func (*Resolver) DisplayPath

func (r *Resolver) DisplayPath(path string) string

DisplayPath formats an absolute or workspace relative path for display purposes. It prioritizes collapsing the home directory to ~, matching the UI design choice.

func (*Resolver) Root

func (r *Resolver) Root() string

Root returns the canonical workspace root path.

func (*Resolver) ValidateAbs

func (r *Resolver) ValidateAbs(path string) (string, error)

ValidateAbs ensures a path is absolute and returns its cleaned version. It returns an error if the path is relative.

Jump to

Keyboard shortcuts

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