package/pkg-golang.mk: make GOPROXY configurable

BR2_GOPROXY now configures the Go module proxy URL used to download Go modules
specified in project go.mod and go.sum files. By default, it uses Google's
official Go module mirror at proxy.golang.org, falling back to direct downloads
if the module is not found in the mirror.

The default value from the toolchain can be read with "go env GOPROXY"

We rely on package developers to audit their dependencies in go.mod and go.sum.

The value can be configured to:
- A comma-separated list of proxy URLs
- "off" to disable all downloads
- "direct" to download directly from source repositories

For more details on Go module proxies:
https://go.dev/ref/mod#module-proxy

Discussion:
https://lore.kernel.org/all/CADvTj4pXO2rwJ8oCzzGNY+OxLuo3uJnDT2PAxbyquw0L6dhfiA@mail.gmail.com/T/#t

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
Signed-off-by: Christian Stewart <christian@aperture.us>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
James Hilliard
2026-10-02 13:26:47 -06:00
committed by Thomas Petazzoni
parent 84a940ebe1
commit f14e138f6f
2 changed files with 17 additions and 1 deletions

View File

@@ -334,6 +334,22 @@ config BR2_LUAROCKS_MIRROR
See http://luarocks.org
config BR2_GOPROXY
string "Go module proxy"
default "https://proxy.golang.org,direct"
depends on BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS
help
The Go module proxy URL used to download Go modules. By
default, it uses the official Go module mirror, falling back
to direct downloads if the module is not found in the mirror.
The value can be one of:
- Comma-separated list of proxy URLs
- "off" to disable all downloads
- "direct" to download directly from source repositories
See https://go.dev/ref/mod#module-proxy
config BR2_CPAN_MIRROR
string "CPAN mirror (Perl packages)"
default "https://cpan.metacpan.org"

View File

@@ -101,7 +101,7 @@ $(2)_POST_PATCH_HOOKS += $(2)_GEN_GOMOD
$(2)_DOWNLOAD_POST_PROCESS = go
$(2)_DL_ENV += \
$$(HOST_GO_COMMON_ENV) \
GOPROXY="https://proxy.golang.org,direct" \
GOPROXY=$$(call qstrip,$$(BR2_GOPROXY)) \
$$($(2)_GO_ENV)
# If building in a sub directory, do the vendoring in there