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
1 Like
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: go command - cmd/go - Go Packages .
1 Like
From the Go wiki.
FileTreeDocumentation (circa go1.9.2)
Modules (circa Go 1.11)
Just read through the docs again, yeah, we still need the GOBIN/GOPATH
configuration. No new updates about getting rid GOPATH
yet.
1 Like
The wiki page title changed† and consequently the URL.
FileTreeDocumentation (old)
FileTree (new)
† its officially discouraged
Some insignificant typograpical improvements and a link to the Modules page added.
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
(Download and install - The Go Programming Language ).
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).
1 Like
system
(system)
Closed
December 27, 2019, 7:44pm
10
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.