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-by: Bryan C. Mills <>
15 files changed
tree: 584704800bc543af666fbc185d128753fbf3e08f
  7. codereview.cfg
  8. main.go
  9. vendor/

Versioned Go Prototype (vgo)

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

See for documents about the design.


Use go get -u

You can also manually git clone the repository to $GOPATH/src/

Report Issues / Send Patches


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

Thank you.