When I enable gomodules and build my go program then the required packages are downloaded.
But I cannot find them in $GOPATH/src/
or in $GOPATH/src/mod
.
Where are they stored?
export GO111MODULE=on
go mod init
go build main.go
go: finding github.com/sirupsen/logrus v1.0.6
go: downloading github.com/sirupsen/logrus v1.0.6
...
What is Go Module. A Module is a collection of Go packages stored in a file tree under $GOPATH/pkg folder with a go. mod file at its root.
go clean -modcache This command is used to clear the mod cache which is stored at $GOPATH/pkg/mod . This command is used to remove the installed packages. The -modcache flag removes the entire module download cache, including unpacked source code of versioned dependencies.
Modules may be downloaded directly from version control repositories or from module proxy servers. A module is identified by a module path, which is declared in a go. mod file, together with information about the module's dependencies. The module root directory is the directory that contains the go.
For Go 1.11, they are stored in
$GOPATH/pkg/mod
I'm on Macos 10.13.6, using go1.11 darwin/amd64
and echo $GOPATH
is empty.
I found my modules in $HOME/go/pkg/mod
Run this in terminal
go env GOMODCACHE
go env - Print all Go environment information
go env NAME - Print specific env var.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With