Skip to content

Commit

Permalink
go_repository: fix missing default GOPROXY (bazelbuild#1602)
Browse files Browse the repository at this point in the history
This helps unblock the Go 1.21.0 upgrade
  • Loading branch information
sluongng authored Aug 14, 2023
1 parent 23e0101 commit adce430
Showing 1 changed file with 7 additions and 0 deletions.
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

0 comments on commit adce430

Please sign in to comment.