lookpath

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDot = errors.New("cannot run executable found relative to current directory")

ErrDot indicates that a path lookup resolved to an executable in the current directory due to ‘.’ being in the path, either implicitly or explicitly. See the package documentation for details.

Note that functions in this package do not return ErrDot directly. Code should use errors.Is(err, ErrDot), not err == ErrDot, to test whether a returned error err is due to this condition.

View Source
var ErrNotFound = errors.New("executable file not found in $PATH")

ErrNotFound is the error resulting if a path search failed to find an executable file.

Functions

func Look

func Look(file string, pathEnv string) (string, error)

LookPath searches for an executable named file in the directories named by the `path` (env. variable). If file contains a slash, it is tried directly and the PATH is not consulted. Otherwise, on success, the result is an absolute path. See the https://cs.opensource.google/go/go/+/refs/tags/go1.21.6:src/os/exec/lp_unix.go;l=52 for further details.

Types

type Error

type Error struct {
	// Name is the file name for which the error occurred.
	Name string
	// Err is the underlying error.
	Err error
}

Error is returned by [LookPath] when it fails to classify a file as an executable.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

Jump to

Keyboard shortcuts

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