Repository navigation
Honor Go settings written with go env -w (#344) - #1356
Merged
Merged
Conversation
socket-patch read GOPRIVATE, GOPROXY, GOMODCACHE and the other Go settings only from the process environment. go itself also reads the per-user file `go env -w` writes ($GOENV, default os.UserConfigDir()/go/env), which is where the Go docs tell users to put them. So a private module path set that way was requested from proxy.golang.org, a configured mirror was bypassed, and a relocated module cache was not found (apply: "matched no installed package"). A new utils::go_env resolver follows go's order: a non-empty environment variable, then the GOENV file (GOENV=off disables it), then the caller's default. goproxy_base, gosumdb_base, the crawler's GOMODCACHE/GOPATH lookup and the GOWORK check now use it. Fixes #344 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
BugBot review |
Mikola Lysenko (mikolalysenko)
enabled auto-merge
October 9, 2026 17:54
Tanmay Singla (Tanmay182003)
approved these changes
Oct 9, 2026
Collaborator
Author
|
bugbot run Generated by Claude Code |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 9825ccf. Configure here.
Mikola Lysenko (mikolalysenko)
disabled auto-merge
October 9, 2026 20:41
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LLM Description written by Claude Code:claude-opus-5-5
Fixes #344
Summary
socket-patch now reads Go settings saved with
go env -wthe same way thegocommand does. Before this,GOPRIVATE,GOPROXYandGOMODCACHEset that way were ignored, so:proxy.golang.orgRoot cause
goproxy_base(vendor/registry_fetch.rs),gosumdb_base(patch/redirect/upstream/client.rs) and the crawler'sget_gomodcache/workspace_in_effect(crawlers/go_crawler.rs) all usedstd::env::varonly. go resolves each setting from the environment, then from the Go environment file, then from its default.Fix
New
utils::go_envresolver, ported fromcmd/go/internal/cfg:cfg.Getenv.$GOENVwhen set (GOENV=offdisables the file), elseos.UserConfigDir()/go/env. That is$XDG_CONFIG_HOMEor~/.configon Linux,~/Library/Application Supporton macOS, and%AppData%on Windows.readEnvFile:KEY=VALUElines, the last one for a key wins, and comments and lowercase lines are skipped.All of
GOPROXY,GONOPROXY,GOPRIVATE,GOSUMDB,GONOSUMDB,GOMODCACHE,GOPATHandGOWORKnow go through it. CLI_CONTRACT.md documents the resolution order.Out of scope:
$GOROOT/go.env(Go 1.21+, the lowest layer). Upstream Go ships it with the built-in defaults, and finding it means runninggo.Tests (red → green)
go env -ware ignored: GOPRIVATE modules are requested from proxy.golang.org, a GOPROXY mirror is bypassed, and a GOMODCACHE cache is not found #344, GOPRIVATE/GOPROXY:registry_fetch::tests::goproxy_base_reads_the_go_env_file. A private module listed in the file is refused instead of sent to the public proxy, a mirror in the file is used, the env var still wins over the file, andGOENV=offfalls back to the default.go env -ware ignored: GOPRIVATE modules are requested from proxy.golang.org, a GOPROXY mirror is bypassed, and a GOMODCACHE cache is not found #344, GOMODCACHE/GOPATH:go_crawler::tests::test_get_gomodcache_reads_the_go_env_file.go env -ware ignored: GOPRIVATE modules are requested from proxy.golang.org, a GOPROXY mirror is bypassed, and a GOMODCACHE cache is not found #344, CLI:e2e_golang::scan_finds_the_cache_named_by_the_go_env_file.scan --jsonwithGOMODCACHEonly in the GOENV file. On main it fails (scannedPackages0); with the fix it finds the module.utils::go_env::tests.goproxy_base_env_precedenceandtest_get_gomodcache_empty_env_fallback_chainnow pinGOENV=off, so a developer's own Go env file can't leak into them.Commands run
cargo test -p socket-patch-core --lib -- go_crawler registry_fetch upstream::client go_env: greencargo test -p socket-patch-cli --test e2e_golang --test spawn_env_hygiene: greencargo clippy --workspace --all-features -- -D warnings: cleancargo fmt --check: the changed files are clean🤖 Generated with Claude Code
Note
Medium Risk
Changes how private modules, proxies, and module-cache paths are resolved for Go scan/patch and upstream restore; mis-parsing could leak private paths to public proxies or miss modules, but behavior is aligned with
goand heavily tested.Overview
Go settings from
go env -ware now honored (#344), matching how thegotoolchain resolves configuration instead of reading only process environment variables.A new
utils::go_envresolver applies env →$GOENVuser file (GOENV=offdisables; otherwiseos.UserConfigDir()/go/env) → caller defaults, with go-styleKEY=VALUEparsing. GOMODCACHE, GOPATH, GOWORK, GOPROXY / GONOPROXY / GOPRIVATE, and GOSUMDB / GONOSUMDB now route through it in the Go crawler, module-proxy upstream fetch, and checksum-database restore paths. CLI_CONTRACT.md documents this resolution order for registry-related Go knobs.Tests add resolver and integration coverage (including an e2e
scanthat finds modules when GOMODCACHE lives only in the go env file); existing precedence tests pinGOENV=offso local developer files do not leak.Reviewed by Cursor Bugbot for commit 9825ccf. Configure here.
Generated by Claude Code