cmd/go/internal/modfetch: cache info and gomod on disk

This on-disk caching was previously done inside package vgo,
but that means that other code calling modfetch directly
does not benefit from the cache entries and does unnecessary
network operations. Fix that.

This CL also renames the local cache directory root from
$GOPATH/src/v to $GOPATH/src/mod.

The "v" stood for versioned, but "mod" seems clearer
(it's the downloaded modules).

This CL also fixes a deadlock in the caching code: one Repo's
GoMod may need to call another repo's Stat and vice versa,
so it can't be that a Repo must only be used from one goroutine
at a time, or else we'll end up with a deadlock. Redefine that
any Repo must be allowed to be used from multiple goroutines
simultaneously and update the code accordingly. This eliminates
the potential deadlock.

This CL also makes the gitrepo implementation work a bit
harder to use its local information before doing any network
operations. In particular, locally-cached tags or commits are
now resolved without consulting the remote repo.

Fixes golang/go#25919.

Change-Id: I3443ffc97a1e3e465c8780fb81f263be3b6d77ae
Reviewed-on: https://go-review.googlesource.com/119475
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
11 files changed
tree: c5c9ddfca9b9376dd630892545e83a61f2e18ca9
  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.