req

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: MIT Imports: 7 Imported by: 5

Documentation

Overview

Package req provides methods to resolve Go oriented tooling paths, and if not found attempts to install on demand.

This simplifies other packages so they don't need to worry about installing tools each time. Instead the packages get installed on demand when called.

Example:

Let's say you run mage secrets:check but don't have gitleaks installed.

The package tasks will run the check, but if the binary for gitleaks isn't found, then it would attempt to run the `go install github.com/zricethezav/gitleaks/v8` command, resolve the path, and provide this pack to the caller.

Overtime, I've started migrating more to this approach as it means you have far less concerns for tools like this to run any install/init style setup, and instead just let it self-setup as needed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetGoPath

func GetGoPath() (gopath string)

GetGoPath returns the GOPATH value.

func QualifyGoBinary

func QualifyGoBinary(binary string) (string, error)

QualifyGoBinary provides a fully qualified path for an installed Go binary to avoid path issues. This uses exec.LookPath to allow resolution of the binary from any provided `PATH` variables, allowing better alternative tooling installation before installing from source.

func ResolveBinaryByInstall

func ResolveBinaryByInstall(app, goInstallCmd string) (qualifiedBinary string, err error)

ResolveBinaryByInstall tries to qualify the tool, looking in all `PATH` locations. If it can't resolve the binary, it will attempt to use a source based install via `go install`, which might be slower, but eliminate failure if not using a pre-installation method such as Aqua, asdf, brew, or other tooling methods.

This can help with running in CI and not having to have a lot of setup code.

Types

This section is empty.

Jump to

Keyboard shortcuts

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