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 imports: rename to internal/imports 2019-05-20 21:49:35 +00:00
fix.go internal/imports: use a module resolver if GOWORK is set 2022-06-24 21:03:09 +00:00
fix_test.go internal/imports: ignore some line directives 2022-04-06 14:24:15 +00:00
imports.go internal: remove unneeded FileSets 2022-06-06 20:47:10 +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 all: go fmt ./... 2021-02-20 03:28:52 +00:00
mkstdlib.go internal/imports: update stdlib index for 1.18 2022-03-16 21:19:09 +00:00
mod.go internal/imports: use a module resolver if GOWORK is set 2022-06-24 21:03:09 +00:00
mod_cache.go all: add copyright notices to files that are missing them 2021-01-06 17:23:47 +00:00
mod_cache_test.go all: add copyright notices to files that are missing them 2021-01-06 17:23:47 +00:00
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 internal/imports: update stdlib index for 1.18 2022-03-16 21:19:09 +00:00