tools/go
Heschi Kreinick 9c309ee22f imports: stop using go/packages for modules
go/packages needs to call `go list` multiple times, which causes
redundant work and slows down goimports. If we reimplement `go list` in
memory, we can reuse state, saving time. `go list` also does work we
don't really need, like adding stuff to go.mod, and skipping that saves
more time.

We start with `go list -m`, which does MVS and such. The remaining work
is mostly mapping import paths and directories through the in-scope
modules to make sure we're giving the right answers. Unfortunately this
is quite subtle, and I don't know where all the traps are. I did my
best.

cmd/go already has tests for `go list`, of course, and packagestest is
not well suited to tests of this complexity. So I ripped off the script
tests in cmd/go that seemed relevant and made sure that our logic
returns the right stuff in each case. I'm sure that there are more cases
to cover, but this hit all the stuff I knew about and quite a bit I
didn't.

Since we may want to use the go/packages code path in the future, e.g.
for Bazel, I left that in place. It won't be used unless the magic env
var is set.

Files in internal and imports/testdata/mod were copied verbatim from
cmd/go.

Change-Id: I1248d99c400c1a0c7ef180d4460b9b8a3db0246b
Reviewed-on: https://go-review.googlesource.com/c/158097
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-01-22 20:29:12 +00:00
..
analysis go/analysis/internal/checker: correct comment grammar 2019-01-22 15:45:57 +00:00
ast go/ast/inspector: fix a small typo 2019-01-10 14:16:07 +00:00
buildutil go/...: make most tests pass with gccgo 2018-06-08 16:58:49 +00:00
callgraph go/...: use recommended issue tracker URLs 2018-12-05 01:41:16 +00:00
cfg go/cfg: a syntactic control-flow graph (CFG) 2018-09-26 00:57:46 +00:00
expect go/expect: rewrite the expectation parser 2018-11-30 19:57:46 +00:00
gccgoexportdata go/gccgoexportdata: correctly handle archive files containing string tables 2016-11-09 21:28:38 +00:00
gcexportdata go/...: use recommended issue tracker URLs 2018-12-05 01:41:16 +00:00
internal go/internal/packagesdriver: fix crash when GOARCH and Go compiler can't be determined 2019-01-02 18:37:24 +00:00
loader go/...: use recommended issue tracker URLs 2018-12-05 01:41:16 +00:00
packages imports: stop using go/packages for modules 2019-01-22 20:29:12 +00:00
pointer go/...: use recommended issue tracker URLs 2018-12-05 01:41:16 +00:00
ssa go/ssa: convert the objlookup tests to the new marker syntax 2018-12-13 15:12:02 +00:00
types go/analysis/passes/printf: changes for analysis API 2018-10-16 19:44:49 +00:00
vcs go/vcs: use Bitbucket v2 REST API 2018-12-18 02:00:41 +00:00