(see also: https://github.com/creachadair/misctools/blob/main/scripts/install-go.sh)
Go allows the definition of named, experimental features, which are established by setting GOEXPERIMENT
in the environment. While some of these features are available at runtime, some must be enabled when building the toolchain itself. An example of the latter is the cacheprog
experiment (as of August 2024).
To enable such an experiment:
- Download a source distribution of Go.
- Unpack the distribution and
cd go/src
. - Set
GOEXPERIMENT
to a comma-separated list of experiments and run./make.bash
.
For example:
curl -sL https://go.dev/dl/go1.23.0.src.tar.gz | tar -x
cd go/src
GOEXPERIMENT=cacheprog ./make.bash
Note
Building from source requires a bootstrap to be installed. The easiest way to do so is to install a binary distribution of the toolchain somewhere in your $PATH
. The pre-built binary installations do not enable experiments by default, but you can use them to bootstrap one that does.