tools/internal/imports
Rob Findley 7cc3be7d11 internal/imports: use a clean GOMODCACHE for the scan root directory
The directories processed by gopathwalk are clean, yet in the scan
callback are assumed to have the root as a prefix. For the module cache,
this root was previous not guaranteed to be clean, if it came from a
GOMODCACHE environment variable. As a result, the computed relative path
may be inaccurate, and may even panic if the unclean root is much longer
than its clean form.

Reproduce the crash of golang/go#67156 in a test, update
scanDirForPackage to be more robust, and fix the uncleanliness of the
module cache root.

Also fix some handling of GOMODCACHE cleanup in imports tests.

Fixes golang/go#67156

Change-Id: Ia899256fed9629b7e753a52feb02b4235bfc8388
Reviewed-on: https://go-review.googlesource.com/c/tools/+/603635
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-08-13 17:53:00 +00:00
..
testdata/mod
fix.go internal/imports: fix starvation in external candidate search 2024-06-11 18:12:39 +00:00
fix_test.go internal/imports: fix starvation in external candidate search 2024-06-11 18:12:39 +00:00
imports.go gopls/internal/golang: work around bug in go/doc 2024-03-29 15:08:21 +00:00
imports_test.go all: add copyright notices to files that are missing them 2021-01-06 17:23:47 +00:00
mkindex.go tools: replace references to obsolete package ioutils 2023-09-12 20:13:37 +00:00
mod.go internal/imports: use a clean GOMODCACHE for the scan root directory 2024-08-13 17:53:00 +00:00
mod_cache.go gopls/internal/golang/completion: honor std symbol versions (unimported) 2024-03-07 20:03:24 +00:00
mod_cache_test.go gopls/internal/cache: share goimports state for GOMODCACHE 2024-02-06 18:49:01 +00:00
mod_go122_test.go cmd/goimports: support workspace vendoring 2024-04-16 16:30:23 +00:00
mod_test.go x/tools: drop go1.18 support 2024-02-29 16:54:26 +00:00
sortimports.go gopls/internal/golang: work around bug in go/doc 2024-03-29 15:08:21 +00:00