execpath

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 7 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 execpath finds the external programs the app runs (gh, git, claude) and runs them.

An app started from the Finder or the Dock inherits launchd's minimal PATH, which lacks Homebrew, ~/.local/bin, and other common install locations. Finder.Find therefore tries the inherited PATH first and then a short list of well-known directories for the current OS. Runner runs a program as an argv, never through a shell.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("executable not found")

ErrNotFound is returned when a program is on neither the search path nor any of the well-known directories.

Functions

This section is empty.

Types

type Finder

type Finder struct {
	// Home is the user's home directory. Home-relative well-known directories are skipped
	// when it is empty.
	Home string

	// Extra lists additional directories to search, before the well-known ones.
	Extra []string
}

Finder resolves a program name to the absolute path of an executable.

func (Finder) Find

func (f Finder) Find(name string) (string, error)

Find returns the absolute path of the named executable. It tries exec.LookPath(name) first, then each extra and well-known directory in order, and returns ErrNotFound naming the program and every directory searched when none has it.

type Runner

type Runner struct {
	Finder Finder
}

Runner runs programs as argv with exec.CommandContext. A name that is not an absolute path is resolved with Finder first.

func (Runner) Run

func (r Runner) Run(ctx context.Context, name string, args ...string) (stdout, stderr []byte, err error)

Run runs name with args and returns what it wrote to stdout and stderr. The error is the lookup or exec error, wrapped; a non-zero exit is an *exec.ExitError in the chain, so callers can read its exit code.

Jump to

Keyboard shortcuts

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