diff --git a/src/cmd/go/internal/modfetch/cache.go b/src/cmd/go/internal/modfetch/cache.go index 1f9cc96c3ec808..d74734c7a93612 100644 --- a/src/cmd/go/internal/modfetch/cache.go +++ b/src/cmd/go/internal/modfetch/cache.go @@ -129,16 +129,18 @@ func (r *cachingRepo) Stat(rev string) (*RevInfo, error) { } info, err = r.r.Stat(rev) if err == nil { - if err := writeDiskStat(file, info); err != nil { - fmt.Fprintf(os.Stderr, "go: writing stat cache: %v\n", err) - } // If we resolved, say, 1234abcde to v0.0.0-20180604122334-1234abcdef78, // then save the information under the proper version, for future use. if info.Version != rev { + file, _, _ = readDiskStat(r.path, info.Version) r.cache.Do("stat:"+info.Version, func() interface{} { return cachedInfo{info, err} }) } + + if err := writeDiskStat(file, info); err != nil { + fmt.Fprintf(os.Stderr, "go: writing stat cache: %v\n", err) + } } return cachedInfo{info, err} }).(cachedInfo)