This is a mirror of https://codeberg.org/pierreprinetti/go-setversion
I am a version selector for Go.
Assumptions:
- you are running on Linux
- you have Go installed on
/usr/bin/go
- I can install as
$GOBIN/go
on your system
Download go-setversion
and save it as $GOBIN/go
.
curl -L https://codeberg.org/pierreprinetti/go-setversion/raw/branch/main/go-setversion > "$GOBIN/go" && chmod +x "$GOBIN/go"
Set the current directory to Go v1.18:
go setversion 1.18
Then, operate as usual:
go build -o myproject .
go-setversion only intercepts calls to go setversion
and passes the rest to the Go version of your choice.
Remove setversion settings for the current directory:
go setversion
Remove setversion settings for the whole system:
./go-setversion reset
or
rm ${XDG_CONFIG_HOME:-${HOME}/.config}/go-setversion/paths.conf
rm -f "$GOBIN/go"
rm -rf ${XDG_CONFIG_HOME:-${HOME}/.config}/go-setversion
When a new Go version is published, set it as the default for your system with (for example):
cd /
go setversion 1.18rc1
go-setversion
saves a map of {directory -> Go version} in a config file. Whenever you call go
, it intercepts the call and bounces it to the Go version you have set for $PWD
.
If the Go version you want is not available on your system, it installs it to $GOBIN
.