#`go install` and GOPATH/GOBIN

8 messages · Page 1 of 1 (latest)

fresh mauve
#

Is there a "best practices" for setting these?

Here is my situation: I use asdf to manage go versions. This works great for dev, but it means when I do go install to install a tool, it puts it in the bin folder associated with the specific go version (defined by asdf). This means that whenever I change versions (or upgrade my global go version), I need to reinstall whatever tools installed with go install. This is a pain and seems wasteful.
I just want tools that are compiled binaries to be installed once - I don't think it needs to be associated with a specific version. If I am tweaking/forking/etc I will clone the repo and build that way.

I think I can solve this via defining GOPATH or GOBIN to something like ~/.local/go, but is that a bad idea? Will it break things? are there better ways to do this?

vast wraith
#

I guess first off, I've never managed go versions

#

There's never been a reason to do so for me (or many others, most likely)

#

That being said, to answer your question, I would set GOBIN but not GOPATH

#

GOBIN is just where binaries are installed, but GOPATH is where Go will look for things like the stdlib

#

(It also houses the module cache, but that will be disk waste rather than breaking anything)

crude edge
#

If you only set GOBIN, it won't breakup anything except override the same name program that already inside the GOBIN

#

and also, since golang is completely backward compatible, and golang doesn't have v2 yet, so there is no point to install more than one go instance