Skip to main content

Module config

Module config 

Source
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::new rejects any URL carrying username()/password() outright — there is no ${VAR} expansion step for $GOENV (unlike npm’s .npmrc), so InvalidEntry::raw and every tracing::warn! here name the as-written value with any embedded userinfo redacted first (see deps_core::net_policy::redact_userinfo).
  • FR-009’s per-hop fail-closed rule is the load-bearing security invariant. An invalid GOPROXY hop is dropped when other valid hops remain; only when every hop is invalid does the whole chain fail closed to deps_core::parser::DependencySource::CustomRegistry. Neither case ever falls back to proxy.golang.org — see GoEnvConfig::resolve_source_for.
  • FR-008’s GOPRIVATE bypass never reaches a configured proxy hop at all — a module whose path matches a GOPRIVATE glob resolves straight to the direct terminal hop, regardless of what GOPROXY is configured to. See GoEnvConfig::resolve_source_for.

See specs/034-go-goproxy-private-registry/spec.md FR-001–FR-016 for the design this module implements.

Structs§

GlobPattern
One GOPRIVATE/GONOPROXY-style glob pattern (FR-007).
GoEnvCache
Per-$GOENV-file-path memoization, mirroring deps_npm::config::NpmConfigCache exactly in shape.
GoEnvConfig
Resolved $GOENV configuration (FR-001–FR-008), consulted per-dependency via Self::resolve_source_for.
GoParseContext
Owned by GoEcosystem, shared across every document it parses.
GoProxyChain
One fully-resolved, ready-to-register GOPROXY chain — produced by GoEnvConfig::goproxy_chain, consumed by GoRegistry::register_chain.
GoProxyUrl
A validated, normalized, https-only Go module proxy URL with no embedded userinfo.
InvalidEntry
A present-but-unusable GOPROXY hop — an invalid URL or a policy-blocked host (FR-009).

Enums§

ChainSeparator
Which fallback rule governs a GOPROXY chain hop’s failure (spec 034 S2).
GoProxyHop
One GOPROXY chain entry (FR-002): either a validated proxy URL, or one of the two sentinel values go help goproxy defines.
GoProxyUrlError
Why a candidate GOPROXY hop URL failed GoProxyUrl::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 $GOENV into a GoEnvConfig (spec FR-001–FR-008).
resolve_with_context
Resolves $GOENV into a GoEnvConfig, reading the already-resolved GoParseContext::goenv_path instead of calling goenv_path itself.