Skip to content

Commit e0227ae

Browse files
cmd/go: accept @hash/branch in mod download
Go get in mod-enabled packages lets you do go get "pkg@<hash>" or "pkg@<branch>". Go internally will switch the hash or branch into a pseudo version. Go mod download should do the same. The bug lied in the fact that the disk cache was not being written when Go converted the hash/branch into a pseduo version. Fixes golang#27947 Change-Id: Ib5b376c65406173c3cd8739254b37a919dff8e8f
1 parent 8256bcd commit e0227ae

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/cmd/go/internal/modfetch/cache.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,16 +129,18 @@ func (r *cachingRepo) Stat(rev string) (*RevInfo, error) {
129129
}
130130
info, err = r.r.Stat(rev)
131131
if err == nil {
132-
if err := writeDiskStat(file, info); err != nil {
133-
fmt.Fprintf(os.Stderr, "go: writing stat cache: %v\n", err)
134-
}
135132
// If we resolved, say, 1234abcde to v0.0.0-20180604122334-1234abcdef78,
136133
// then save the information under the proper version, for future use.
137134
if info.Version != rev {
135+
file, _, _ = readDiskStat(r.path, info.Version)
138136
r.cache.Do("stat:"+info.Version, func() interface{} {
139137
return cachedInfo{info, err}
140138
})
141139
}
140+
141+
if err := writeDiskStat(file, info); err != nil {
142+
fmt.Fprintf(os.Stderr, "go: writing stat cache: %v\n", err)
143+
}
142144
}
143145
return cachedInfo{info, err}
144146
}).(cachedInfo)

0 commit comments

Comments
 (0)