LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

go-install

compile and install Go packages and binaries

TLDR

Install a package from current module
$ go install
copy
Install specific package
$ go install [package]
copy
Install latest version of a tool
$ go install [example.com/tool]@latest
copy
Install specific version
$ go install [example.com/tool]@v1.2.3
copy
Install with verbose output
$ go install -v [package]
copy

SYNOPSIS

go install [build flags] [packages]

DESCRIPTION

go install compiles and installs packages and their dependencies. Executables are installed to the directory named by the GOBIN environment variable, defaulting to $GOPATH/bin or $HOME/go/bin. When used with an @version suffix, it installs in module-aware mode regardless of the current directory, ignoring any go.mod present.

PARAMETERS

-v

Print package names as compiled.
-n
Print commands without executing.
-x
Print commands as executed.
@version
Install specific version (latest, v1.2.3, etc.).

INSTALL

sudo apt install gccgo-go
copy
sudo dnf install gcc-go
copy
sudo pacman -S gcc-go
copy
sudo apk add gcc-go
copy
sudo zypper install gcc-go
copy
brew install go
copy
nix profile install nixpkgs#go
copy

CAVEATS

Use @latest or @version to install tools independent of current module. Without a version suffix, go install uses dependencies from the current module's go.mod.

HISTORY

Since Go 1.16, go install is the recommended way to build and install commands at a specific version, taking over that role from go get, which was fully restricted from doing so as of Go 1.18.

SEE ALSO

go(1), go-build(1), go-get(1)

RESOURCES

Copied to clipboard
Kai