Where go get download file?


(Jameswang2015) #1

I’m wondering where the go get download and put the files when I set up GOPATH?

When using GO111MODULE=on, does go get still download the file or just cashe it based on go.mod file? new to cashe, so does these cashed file disappear when I shut down my machine?

Thanks
James


(Holloway) #2

go get download and installed into GOBIN. If GOPATH is set and GOBIN is not, GOBIN automatically becomes GOPATH/bin.

go get module caches the module in GOPATH/pkg/mod. The cache is persistent so you won’t lose it when you shutdown the machine.


To know your current settings, simply use env like (I’m on Linux so this is mine):

$ go env
GOARCH="amd64"
GOBIN="/home/u0/bin"
GOCACHE="/home/u0/.cache/go-build"
...
GOPATH="/home/u0"
...
GOROOT="/usr/local/go"
...
$

More read up: https://golang.org/cmd/go/#hdr-GOPATH_environment_variable.


(Holloway) #5

Just read through the docs again, yeah, we still need the GOBIN/GOPATH configuration. No new updates about getting rid GOPATH yet. :sleepy:


(Holloway) #7

No worries, OP has a different thread and is aware of the “Go Module vs. GOPATH” development and how to approach them.

As far as all the documentations, we still need to set GOPATH. Even the installation guide is still requiring new setup to set GOPATH (https://golang.org/doc/install#testing).

Quote:

GOPATH and Modules
When using modules, GOPATH is no longer used for resolving imports. However, it is still used to store downloaded source code (in GOPATH/pkg/mod) and compiled commands (in GOPATH/bin).

(Eric Lindblad) #9

wiki: reinsert FileTree page #34590