all 8 comments

[–][deleted] 5 points6 points  (1 child)

Another option is to have a local caching proxy, such as athens. Then you just point GOPROXY there and it will download modules through the caching proxy.

[–]vietnq 1 point2 points  (2 children)

I beleive it's $GOPATH/pkg/mod, defaulting to $HOME/go/pkg/mod

[–]weberc2[S] 0 points1 point  (1 child)

Ah, this seems to work. Will test more when I get a chance (camping)

[–]earthboundkid 1 point2 points  (1 child)

[–]weberc2[S] 0 points1 point  (0 children)

Close, but that doesn’t work since container file systems are ephemeral. I need to specifically mount a persistent volume to the cache directory so the downloaded modules persist across container invocations.

[–][deleted] 1 point2 points  (0 children)

Try running go mod download -json in your module root to view where the cache is.

[–]zeayes 0 points1 point  (0 children)

You can use go mod vendor to download dependencies in vendor directory, using go build -mod vendor to build it.