go/internal/imports
Robert Findley e1ec1f3230 internal/imports: use a module resolver if GOWORK is set
Previously, gopls would fall back on a gopath resolver when running
goimports from a directory containing go.work (but not go.mod). Fix this
by update the code to recognize that GOWORK also puts goimports into
module mode.

All the work to _support_ go.work had already been done, but the tests
were only passing because they were setting GO111MODULE=on explicitly
(and therefore GOMOD=/dev/null was satisfying the pre-existing check).

Also add a test for the regression in gopls.

Fixes golang/go#52784

Change-Id: I31df6f71a949a5668e8dc001b3ee25ad26f2f927
Reviewed-on: https://go-review.googlesource.com/c/tools/+/413689
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2022-06-24 21:03:09 +00:00
..
testdata/mod
fix.go internal/imports: use a module resolver if GOWORK is set 2022-06-24 21:03:09 +00:00
fix_test.go
imports.go internal: remove unneeded FileSets 2022-06-06 20:47:10 +00:00
imports_test.go
mkindex.go
mkstdlib.go
mod.go internal/imports: use a module resolver if GOWORK is set 2022-06-24 21:03:09 +00:00
mod_cache.go
mod_cache_test.go
mod_test.go internal/imports: use a module resolver if GOWORK is set 2022-06-24 21:03:09 +00:00
sortimports.go internal: remove unneeded FileSets 2022-06-06 20:47:10 +00:00
zstdlib.go