Update golang software, but keep installed go apps/packages

147 views Asked by At

I am on Linux (debian) and want to update a global go installation. (not installed from debian repo, but manual install into /usr/local)

The installation/update instructions on go.dev/doc/install state:

Remove any previous Go installation by deleting the /usr/local/go folder [...] then extract the archive [...] into /usr/local, creating a fresh Go tree in /usr/local/go

But I installed some go apps using go install (e.g. go-sendxmpp), which reside now in /usr/local/go/bin, /usr/local/go/pkg

Therefore my question: How can I update the Go software without also deleting all my installed go apps? What am I missing here?

1

There are 1 answers

0
Douglas Ealasaid On

Move the executables to a different directory. Update your environment variables to install to a different directory.

go install installs executables to the directory named by the GOBIN environment variable, which defaults to $GOPATH/bin or $HOME/go/bin if the GOPATH environment variable is not set.

If go install installed go-sendxmpp to /usr/local/go/bin, then you set GOBIN to /usr/local/go/bin or GOPATH to /usr/local/go. Set these environment variables to point somewhere else. It's typical to point them a personal directory or not set them at all.