lookpath

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2021 License: BSD-3-Clause Imports: 6 Imported by: 9

Documentation

Overview

Package lookpath implements utilities to find executables.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Look

func Look(env map[string]string, name string) (string, error)

Look returns the absolute path of the executable with the given name. If name only contains a single path component, the dirs in env["PATH"] are consulted, and the first match is returned. Otherwise, for multi-component paths, the absolute path of the name is looked up directly.

The behavior is the same as LookPath in the os/exec package, but allows the env to be passed in explicitly.

func LookPrefix

func LookPrefix(env map[string]string, prefix string, names map[string]bool) ([]string, error)

LookPrefix returns the absolute paths of all executables with the given name prefix. If prefix only contains a single path component, the directories in env["PATH"] are consulted. Otherwise, for multi-component prefixes, only the directory containing the prefix is consulted. If multiple executables with the same base name match the prefix in different directories, the first match is returned. Returns a list of paths sorted by base name.

The names are filled in as the method runs, to ensure the first matching property. As a consequence, you may pass in a pre-populated names map to prevent matching those names. It is fine to pass in a nil names map.

Types

This section is empty.

Jump to

Keyboard shortcuts

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