GoLand module proxy configuration lacks per‑module override for private repositories
0 reputation · 06 Mar 2025, 21:31 UTC
0 reputation · 06 Mar 2025, 21:31 UTC
The goal is to prevent accidental exposure of private Go modules when a public proxy is configured in GoLand’s global module proxy setting.
Currently GoLand exposes only a single "Go module proxy" field under Settings > Go > GOROMOD > Module Proxy, with no way to specify different proxies for individual modules or to suppress proxy usage for private dependencies. The IDE does not emit a warning or log entry when a private module is resolved through the public proxy, and it is unclear whether the vendor command or module refresh respects a per‑module GOPROXY=off override.
35275 reputation · 06 Mar 2025, 23:28 UTC
GoLand does not provide a native GUI table for per-module proxy overrides. Instead, it relies on the standard Go toolchain's logic. To prevent private modules from being requested via a public proxy, you must use the GOPRIVATE environment variable.
The GOPRIVATE variable tells the Go toolchain to bypass both the configured GOPROXY and the checksum database (GOSUMDB) for any module path that matches the specified patterns. This ensures that private dependencies are fetched directly from the source (e.g., via SSH or HTTPS) rather than being leaked to a public proxy.
To configure this in GoLand:
GOPROXY), there is often no dedicated GOPRIVATE field in the basic UI.GOPRIVATE=github.com/your-org/* to the Environment field.Because GoLand acts as a wrapper around the Go CLI, it does not implement its own proxy routing engine. Consequently:
go command. If a proxy returns a 404 or 410 for a private repo, it will appear in the Build or Event Log window.go mod vendor or the IDE's module refresh trigger the Go toolchain. If GOPRIVATE is correctly set in the environment where the IDE is running, these operations will bypass the proxy for matching modules.To verify that your private modules are bypassing the proxy, run the following command in the GoLand integrated terminal:
go env GOPROXY GOPRIVATE
Then, attempt to list the modules. If GOPRIVATE is working, the Go tool will attempt a direct connection to your VCS provider rather than the proxy URL:
go list -m all
Diagnostic Detail Needed: Are you using a project-specific .env file or a global OS environment configuration? This determines whether you should set GOPRIVATE in the IDE's global settings or within the specific Run/Debug configuration.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.