Lightweight Go version manager
Go to file
Pierre Prinetti c1e3ff2ddb
Documentation tweaks
2023-07-07 11:10:39 +02:00
LICENSE.txt Rename the license file 2023-07-07 11:01:43 +02:00 Documentation tweaks 2023-07-07 11:10:39 +02:00
go-setversion Only read the first matching config line 2022-03-23 09:56:13 +01:00

go setversion

I am a version selector for Go.


  • 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 > "$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


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

How it works

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.