go
goenv
A reference page for the goenv resource
The goenv resource installs goenv, a Go version manager modelled after pyenv and rbenv that lets you install and switch between multiple Go versions. On macOS it is installed via Homebrew; on Linux it is cloned from GitHub into ~/.goenv.
Parameters:
-
goVersions: (array[string]) Go versions to install via goenv (e.g.
["1.22.0", "1.21.5"]). Versions must match those available fromgoenv install --list. Codify adds missing versions and removes versions that are no longer listed. -
global: (string) The Go version to set as the global default (equivalent to running
goenv global <version>). The version must be ingoVersionsor already installed on the system.
Example usage:
Install goenv with a single Go version
[
{
"type": "goenv",
"goVersions": ["1.22.0"],
"global": "1.22.0"
}
]Install goenv with multiple Go versions
[
{
"type": "goenv",
"goVersions": ["1.21.0", "1.22.0", "1.23.0"],
"global": "1.23.0"
}
]Install goenv without installing any Go versions
[
{
"type": "goenv"
}
]Notes:
- On macOS, Homebrew must be installed before applying the goenv resource. The homebrew resource can install it. The
mercurialandbisonpackages are installed automatically as part of the goenv install. - On Linux, several system dependencies are required (
curl,git,mercurial,make,binutils,bison,gcc,build-essential). Codify installs these automatically via the system package manager before cloning goenv. - On Linux, goenv is cloned to
~/.goenvand added toPATHin your shell RC file. On macOS, Homebrew manages the installation path. - After applying, open a new terminal session (or source your shell RC file) for the
goenvshims andGOROOT/GOPATHenvironment variables to become active. - To find available Go versions, run
goenv install --listafter installing goenv.