all: clear GOMODCACHE in tests

Various test setups set GOPATH expecting that it will affect GOMODCACHE.
If GOMODCACHE is explicitly set in the test's environment, that doesn't
happen. Clear the value out as needed.

Change-Id: I3520d672ace5c1e13783fd078828212bef7d1c01
Reviewed-on: https://go-review.googlesource.com/c/tools/+/265177
Trust: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
diff --git a/go/packages/packagestest/modules.go b/go/packages/packagestest/modules.go
index 4608766..42b6206 100644
--- a/go/packages/packagestest/modules.go
+++ b/go/packages/packagestest/modules.go
@@ -163,6 +163,7 @@
 	exported.Config.Env = append(exported.Config.Env,
 		"GO111MODULE=on",
 		"GOPATH="+filepath.Join(exported.temp, "modcache"),
+		"GOMODCACHE=",
 		"GOPROXY="+proxydir.ToURL(modProxyDir),
 		"GOSUMDB=off",
 	)
diff --git a/internal/imports/mod_test.go b/internal/imports/mod_test.go
index 5d73c88..c6bbe56 100644
--- a/internal/imports/mod_test.go
+++ b/internal/imports/mod_test.go
@@ -688,6 +688,7 @@
 	env := &ProcessEnv{
 		Env: map[string]string{
 			"GOPATH":      filepath.Join(dir, "gopath"),
+			"GOMODCACHE":  "",
 			"GO111MODULE": "on",
 			"GOSUMDB":     "off",
 			"GOPROXY":     proxydir.ToURL(proxyDir),