cmd/go/internal/vgo: allow vgo get of module with no package in root

Historically "go get" has meant both "download these packages" and
"install these packages". For example "go get rsc.io/github/issue"
downloads that package but also builds and installs it (into $GOBIN/issue).
Similarly "go get golang.org/x/text/number" downloads, builds, and
installs that package (not a package main).

If one needs to just download a whole repo, it has always tripped
up users that "go get golang.org/x/text" fails, because there are no
Go source files in that directory (the root of that repo, it turns out).

Go modules compound this problem, because it is quite natural
to want to run "go get golang.org/x/text@v0.1.0" to add (or to
upgrade or downgrade to) that specific version of golang.org/x/text.

This CL changes "go get" to make this common usage not an error:
if the path is successfully identified as a directory within a known
module, then if there's no code there, "go get" just skips the
"build and install" step, instead of reporting an error.
This way, command installations like "go get rsc.io/github/issue"
continue to work, but now module installations like "go get golang.org/x/text"
or "go get golang.org/x/text@v0.1.0" also now succeed.

Fixes golang/go#24008.

Change-Id: I977ab448bc13a4391e85f63052b8373e30f77026
Reviewed-on: https://go-review.googlesource.com/120995
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 files changed
tree: c3e89fdceccffd11986501b35d274a538eb9b865
  1. vendor/
  2. AUTHORS
  3. codereview.cfg
  4. CONTRIBUTING.md
  5. CONTRIBUTORS
  6. LICENSE
  7. main.go
  8. PATENTS
  9. README.md
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.