Skip to content

Commit 668634b

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

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-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, _ = CachePath(module.Version{Path: r.path, Version: info.Version}, "info")
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)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
env GO111MODULE=on
2+
3+
# Testing mod download with non semantic versions; turn off proxy.
4+
[!net] skip
5+
[!exec:git] skip
6+
env GOPROXY=
7+
8+
go mod download rsc.io/quote@a91498bed0a73d4bb9c1fb2597925f7883bc40a7
9+
exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v0.0.0-20180709162918-a91498bed0a7.info
10+
exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v0.0.0-20180709162918-a91498bed0a7.mod
11+
exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v0.0.0-20180709162918-a91498bed0a7.zip
12+
13+
go mod download rsc.io/quote@master
14+
exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v0.0.0-20180710144737-5d9f230bcfba.info
15+
exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v0.0.0-20180710144737-5d9f230bcfba.mod
16+
exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v0.0.0-20180710144737-5d9f230bcfba.zip
17+
18+
19+
-- go.mod --
20+
module m
21+
22+
-- m.go --
23+
package m

0 commit comments

Comments
 (0)