Skip to content

pierreprinetti/go-setversion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

This is a mirror of https://codeberg.org/pierreprinetti/go-setversion


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

Install/Update

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"

Use

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.


Reset

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

Uninstall

rm -f "$GOBIN/go"
rm -rf ${XDG_CONFIG_HOME:-${HOME}/.config}/go-setversion

Tip

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.