-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: cmd/go: add GOPROXY=cache to rely only on module cache #43646
Comments
|
Just so others find this issue more easily via keywords on google: I was using "offline mode" in my search. |
In module mode, when all module dependencies are given with canonical versions and the version is found in the cache, set GOPROXY to file://$(go env GOMODCACHE)/cache/download so that "go get" skips querying the proxy. Related: golang/go#43646 (proposal for GOPROXY=cache)
Use case: for So, as a workaround for that However, it would be appreciated if |
In module mode, when all module dependencies are given with canonical versions and the version is found in the cache, set GOPROXY to file://$(go env GOMODCACHE)/cache/download so that "go get" skips querying the proxy. Related: golang/go#43646 (proposal for GOPROXY=cache)
Does it fit the need from this proposal? |
@dolmen I don't think so, because multiple commands try to resolve |
The documentation about resolving packages to a module claims:
|
Right, I got slightly confused with |
Ok, so in |
That's how I would imagine it, yes, and it's what I understood from #43646 (comment). It's worth noting that "latest" might be out of date in such a cache/offline mode, but that's by design. |
When I try to import a yet-unrequired module, e.g.
and I run
go mod tidy
, while not connected to the internet, I get an errorThat makes sense - the proxy is not reachable. However, my module cache contains a usable version of this module:
So, it might be a reasonable course of action for me, to just use the version I have in the cache - whether it is the latest, or not. If I want to do that, as far as I can tell, either
a) I have to look up what versions I have in my cache and run
go get rsc.io/[email protected]
, to updatego.mod
. It would be great, if that could be automated, orb) set
GOPROXY=file:///home/mero/pkg/mod/cache/download
and rungo mod tidy
Both of these can be considered somewhat clunky (and the latter is not very discoverable). I would like to suggest to make this easier. There are several ways this could happen:
go mod tidy
or similar and a network error happens. IMO that would be the most convenient - it also has the downside of unexpectedly adding an outdated version of the module.-mod
flag that is equivalent to-mod=mod
, but only touching the local cache.go mod tidy
(and similar), to use the local cache as a proxy (essentially automate setting the environment variable).It's also fine, if this is deemed WAI, of course. I just thought I would suggest it after the case came up on golang-nuts.
The text was updated successfully, but these errors were encountered: