igo -i for the first time, igo writes a shell activator script to ~/.igo. This script sets the environment variables your shell needs to find the correct Go binaries and adjusts your PATH so the igo shims take precedence.
Add the activator to your shell config
After igo creates~/.igo, source it from your shell configuration file so it runs in every new terminal session.
- zsh
- bash
- other
Add the following line to your Then apply the change without restarting your terminal:
~/.zshrc:What the activator does
The~/.igo script performs the following steps every time your shell starts:
-
Guards against double-sourcing. If
IGO_SOURCEDis already set in the environment, the script returns immediately. This prevents PATH from being prepended multiple times in nested shell sessions. -
Sets core igo variables. Three variables are exported to establish the workspace layout:
IGO_ROOT— the workspace root (~/go)IGO_SHIMS— the shims directory (~/go/shims)IGO_BIN— the active binary directory (~/go/bin)
-
Prepends shims and bin to PATH. The script checks whether
IGO_SHIMSis already inPATH. If not, it prepends bothIGO_SHIMSandIGO_BINso igo’s shims resolve first. -
Reads the active version and sets Go environment variables. If
~/go/versionexists, its contents are read to determine the active version string. Four Go environment variables are then exported pointing at that version’s directories. -
Defines
igo-rehash. A no-op shell function namedigo-rehashis defined as a placeholder for future shim regeneration logic.
Environment variables
After sourcing~/.igo, the following environment variables are available in your shell:
| Variable | Value | Description |
|---|---|---|
IGO_ROOT | ~/go | igo workspace root |
IGO_SHIMS | ~/go/shims | Shim scripts directory, prepended to PATH |
IGO_BIN | ~/go/bin | Active Go binaries, prepended to PATH |
GOROOT | ~/go/versions/<ver>/go | Go standard library root |
GOBIN | ~/go/versions/<ver>/go/bin | Directory where go install places binaries |
GOPATH | ~/go/versions/<ver> | Go workspace path |
GOMODCACHE | ~/go/versions/<ver>/go/pkg/mod | Module download cache |
<ver> is the version string read from ~/go/version (e.g. 1.23.4).
If
~/go/version does not exist (no version has been activated yet), the GOROOT, GOBIN, GOPATH, and GOMODCACHE variables are not exported. Run igo -i <version> to install and activate your first Go version.Activator script template
The following is the full content of the activator script that igo writes to~/.igo: