Skip to content
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

go_repository: fix missing default GOPROXY #1602

Merged
merged 2 commits into from
Aug 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions internal/go_repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ Authorization: Bearer RANDOM-TOKEN
# We can't disable timeouts on Bazel, but we can set them to large values.
_GO_REPOSITORY_TIMEOUT = 86400

# Default value from `go env GOPROXY`
_GOPROXY_DEFAULT = "https://proxy.golang.org,direct"

def _go_repository_impl(ctx):
# TODO(#549): vcs repositories are not cached and still need to be fetched.
# Download the repository or module.
Expand Down Expand Up @@ -237,6 +240,10 @@ def _go_repository_impl(ctx):

env.update({k: ctx.os.environ[k] for k in env_keys if k in ctx.os.environ})

# Since Go 1.21.0, GOPROXY must be set to a non-empty value.
if "GOPROXY" not in env:
env["GOPROXY"] = _GOPROXY_DEFAULT

if fetch_repo_args:
# Disable sumdb in fetch_repo. In module mode, the sum is a mandatory
# attribute of go_repository, so we don't need to look it up.
Expand Down