cmd/go/internal/modload: finish Import implementation

modload.Import now means "figure out what this import means in the main module",
including searching for a module to add to go.mod if the import is missing.
(Previously it only did the search.)

Fix Import to handle overlapping module file trees correctly:
the fact that x/y/z is in the build list does not mean it is the
module that must provide x/y/z/v2/w or even x/y/z/w.

The definition of "go get x@v" is now easy to explain: if x is a module path,
go get is talking about that module. Otherwise go get is talking about the
module that provides or would provide x if encountered as an import in the
main module.

Simplify the package load process by using the new Import to eliminate
the separate doMissing parallel pass, as suggested by Bryan in an
earlier code review.

Drop modload.SrcMod in favor of modfetch.SrcMod,
and guard against SrcMod unset (filepath.Join(x, y) treats x="" as like x="."),
which can happen in tests.

Fixes golang/go#24851.
Fixes golang/go#26048.
Fixes golang/go#26250.

Change-Id: I16abfa0c095492fc10ccd75f5857c1c087935867
Reviewed-on: https://go-review.googlesource.com/123095
Reviewed-by: Bryan C. Mills <bcmills@google.com>
15 files changed
tree: 584704800bc543af666fbc185d128753fbf3e08f
  1. AUTHORS
  2. CONTRIBUTING.md
  3. CONTRIBUTORS
  4. LICENSE
  5. PATENTS
  6. README.md
  7. codereview.cfg
  8. main.go
  9. vendor/
README.md

Versioned Go Prototype (vgo)

This repository holds a prototype of what the go command might look like with integrated support for package versioning.

See research.swtch.com/vgo for documents about the design.

Download/Install

Use go get -u golang.org/x/vgo.

You can also manually git clone the repository to $GOPATH/src/golang.org/x/vgo.

Report Issues / Send Patches

See CONTRIBUTING.md.

This is still a very early prototype. You are likely to run into bugs. Please file bugs in the main Go issue tracker, golang.org/issue, and put the prefix x/vgo: in the issue title.

Thank you.