So that developers can make use of --experimental_remote_downloader, which can provide mirroring and other benefits.
A sketch of how this can work:
- Facts contain an entry for each .mod with importpath, version, sum. This set may be stale or incomplete.
- When preparing the synthetic workspace, we list .mod files needed based on require directives and module tags. This set may also be incomplete.
- For each .mod file:
- Skip if
GOPRIVATE or GONOPROXY matches importpath. Each variable contains a list of glob patterns that may match a prefix of the module path. This avoids disclosure of a private module name to an untrusted public proxy.
-Skip if sum is not known.
- Use
module_ctx.download to attempt to download the .mod file into GOMODCACHE. Typically GOMODCACHE will be go_repository_cache. Download even if the file is already present, since we want to populate the download cache too. Tolerate errors: this is best effort. The URL should be constructed from only the first on the GOPROXY list; don't attempt to handle direct, cache, or fall back to other servers.
- Run
go list -m -json all, as we do now.
- Return facts for all .mod files mentioned in the go list -m output so that the facts are not incomplete on the next run.
Follow-up to #2418
So that developers can make use of
--experimental_remote_downloader, which can provide mirroring and other benefits.A sketch of how this can work:
GOPRIVATEorGONOPROXYmatchesimportpath. Each variable contains a list of glob patterns that may match a prefix of the module path. This avoids disclosure of a private module name to an untrusted public proxy.-Skip if sum is not known.
module_ctx.downloadto attempt to download the .mod file intoGOMODCACHE. TypicallyGOMODCACHEwill bego_repository_cache. Download even if the file is already present, since we want to populate the download cache too. Tolerate errors: this is best effort. The URL should be constructed from only the first on theGOPROXYlist; don't attempt to handle direct, cache, or fall back to other servers.go list -m -json all, as we do now.Follow-up to #2418