Skip to content

go_deps: download .mod files through Bazel whenever possible #2433

Description

@jayconrod

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions