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
Run-TryBot: Russ Cox <>
Reviewed-by: Bryan C. Mills <>
11 files changed
tree: c5c9ddfca9b9376dd630892545e83a61f2e18ca9
  1. vendor/
  3. codereview.cfg
  7. main.go

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.