You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Resolve GOPATH and GOMODCACHE through one go_env helper instead of two drifting copies #1834
[agent] Filed by the scheduled architecture audit (audit-core). Register: register.
Kind: refactor. Register ID: A03.
Problem
The crate applies Go's default for "GOMODCACHE, else the first GOPATH entry's pkg/mod, else $HOME/go/pkg/mod" in two places, and the two copies differ:
crawlers/go_crawler.rs#L185-L209get_gomodcache takes the first non-empty GOPATH entry. If GOPATH has only empty entries (for example :), it falls through to fs::home_dir()/go/pkg/mod.
utils/go_installed_tools.rs#L176-L186 builds gopaths, which comes out empty in the same case. It then gets user_cache = None and never falls back to the home default. It also re-filters go_env results with .filter(|v| !v.is_empty()), which does nothing because go_env already drops empty values.
So for the same environment, the crawler and the stale-installed-tool audit can disagree about which directory is the module cache.
Proposed change
Add pub(crate) fn gopath_entries(home: Option<&Path>) -> Vec<PathBuf> and pub(crate) fn gomodcache(home: Option<&Path>) -> Option<PathBuf> to utils/go_env.rs. That is about 20 lines, with one rule for empty entries and the home fallback.
Use them from both get_gomodcache and go_installed_tools, and delete the redundant empty filters.
Pick the behavior that matches go env GOMODCACHE for a GOPATH of only empty entries. Go treats it as unset, so fall back to the home default.
Size: 3 files, about +25/−25.
Acceptance criteria
No change for normal environments.
New unit tests on the helpers (injected env through go_env_with) cover: GOMODCACHE set, multi-entry GOPATH, GOPATH of only empty entries, and no GOPATH.
The existing go_crawler and go_installed_tools tests pass.
[agent] Claiming this issue (shared root cause: the GOMODCACHE / GOPATH default is computed twice and the copies disagree on a GOPATH of only empty entries). Branch: agent/fix-go-modcache-default. Claim-ID: 2026-10-30T03:21:18Z-7c5386
Activity
audit-core: first file-by-file run (28 utils files, A01-A13, #1832-#1834
mikolalysenko commentedon Oct 30, 2026
[agent] Claiming this issue (shared root cause: the GOMODCACHE / GOPATH default is computed twice and the copies disagree on a GOPATH of only empty entries). Branch: agent/fix-go-modcache-default. Claim-ID: 2026-10-30T03:21:18Z-7c5386
Generated by Claude Code
mikolalysenko commentedon Oct 30, 2026
[agent] Draft PR: #1876
Generated by Claude Code