Expand description
$GOENV discovery and GOPROXY/GOPRIVATE resolution.
Go persists go env -w-set variables in a single KEY=VALUE file ($GOENV, defaulting to
os.UserConfigDir()/go/env) rather than a project manifest — unlike Cargo/npm/PyPI, whose
private-registry config lives inside or alongside the workspace being parsed. This module
resolves that file once per process (memoized, mtime-gated — see GoEnvCache) into a
GoEnvConfig consulted by every go.mod parse.
§Security model (read before touching this module)
$GOENV is a process-wide, user-owned file, not workspace-controlled content — but the
resolved GOPROXY chain still names hosts a cloned repository’s dependencies get resolved
against, so the same discipline Cargo/npm/PyPI apply carries over:
- No credential-shaped value is ever parsed (FR-014/NFR-001).
GoProxyUrl::newrejects any URL carryingusername()/password()outright — there is no${VAR}expansion step for$GOENV(unlike npm’s.npmrc), soInvalidEntry::rawand everytracing::warn!here name the as-written value with any embedded userinfo redacted first (seedeps_core::net_policy::redact_userinfo). - FR-009’s per-hop fail-closed rule is the load-bearing security invariant. An invalid
GOPROXYhop is dropped when other valid hops remain; only when every hop is invalid does the whole chain fail closed todeps_core::parser::DependencySource::CustomRegistry. Neither case ever falls back toproxy.golang.org— seeGoEnvConfig::resolve_source_for. - FR-008’s
GOPRIVATEbypass never reaches a configured proxy hop at all — a module whose path matches aGOPRIVATEglob resolves straight to thedirectterminal hop, regardless of whatGOPROXYis configured to. SeeGoEnvConfig::resolve_source_for.
See specs/034-go-goproxy-private-registry/spec.md FR-001–FR-016 for the design this module
implements.
Structs§
- Glob
Pattern - One
GOPRIVATE/GONOPROXY-style glob pattern (FR-007). - GoEnv
Cache - Per-
$GOENV-file-path memoization, mirroringdeps_npm::config::NpmConfigCacheexactly in shape. - GoEnv
Config - Resolved
$GOENVconfiguration (FR-001–FR-008), consulted per-dependency viaSelf::resolve_source_for. - GoParse
Context - Owned by
GoEcosystem, shared across every document it parses. - GoProxy
Chain - One fully-resolved, ready-to-register
GOPROXYchain — produced byGoEnvConfig::goproxy_chain, consumed byGoRegistry::register_chain. - GoProxy
Url - A validated, normalized, https-only Go module proxy URL with no embedded userinfo.
- Invalid
Entry - A present-but-unusable
GOPROXYhop — an invalid URL or a policy-blocked host (FR-009).
Enums§
- Chain
Separator - Which fallback rule governs a
GOPROXYchain hop’s failure (spec 034 S2). - GoProxy
Hop - One
GOPROXYchain entry (FR-002): either a validated proxy URL, or one of the two sentinel valuesgo help goproxydefines. - GoProxy
UrlError - Why a candidate
GOPROXYhop URL failedGoProxyUrl::new’s validation.
Constants§
- GOPRIVATE_
CHAIN_ KEY - Fixed routing key for the
GOPRIVATE-bypass chain (FR-008).
Functions§
- goenv_
path - Resolves
$GOENV’s path (FR-001). - resolve
- Resolves
$GOENVinto aGoEnvConfig(spec FR-001–FR-008). - resolve_
with_ context - Resolves
$GOENVinto aGoEnvConfig, reading the already-resolvedGoParseContext::goenv_pathinstead of callinggoenv_pathitself.