Skip to content

Commit 720eade

Browse files
committed
cmd/go: do not embed checksums when building with vendor
Fixes #46400 Tested: Ran go test cmd/go Change-Id: I60655129c55d40a70a13ed23937ef990f315fd73 Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest Reviewed-on: https://go-review.googlesource.com/c/go/+/564195 Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Sam Thanawalla <samthanawalla@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Commit-Queue: Sam Thanawalla <samthanawalla@google.com>
1 parent b2a169b commit 720eade

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/cmd/go/internal/load/pkg.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2306,7 +2306,7 @@ func (p *Package) setBuildInfo(ctx context.Context, autoVCS bool) {
23062306
}
23072307
if mi.Replace != nil {
23082308
dm.Replace = debugModFromModinfo(mi.Replace)
2309-
} else if mi.Version != "" {
2309+
} else if mi.Version != "" && cfg.BuildMod != "vendor" {
23102310
dm.Sum = modfetch.Sum(ctx, module.Version{Path: mi.Path, Version: mi.Version})
23112311
}
23122312
return dm
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# This test verifies that GOMODCACHE does not affect whether checksums are embedded
2+
# with vendored files.
3+
# See issue #46400
4+
[short] skip 'builds and links a binary twice'
5+
go mod tidy
6+
go mod vendor
7+
8+
go build -mod=vendor
9+
go version -m example$GOEXE
10+
cp stdout version-m.txt
11+
12+
env GOMODCACHE=$WORK${/}modcache
13+
go build -mod=vendor
14+
go version -m example$GOEXE
15+
cmp stdout version-m.txt
16+
17+
-- go.mod --
18+
module example
19+
go 1.22
20+
require rsc.io/sampler v1.3.0
21+
22+
-- main.go --
23+
package main
24+
25+
import (
26+
"fmt"
27+
"rsc.io/sampler"
28+
)
29+
30+
func main() {
31+
fmt.Println(sampler.Hello())
32+
}

0 commit comments

Comments
 (0)