Skip to content

Commit

Permalink
cmd/go: do not embed checksums when building with vendor
Browse files Browse the repository at this point in the history
Fixes golang#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 <[email protected]>
Run-TryBot: Sam Thanawalla <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Commit-Queue: Sam Thanawalla <[email protected]>
  • Loading branch information
samthanawalla authored and ezz-no committed Feb 17, 2024
1 parent edb7c67 commit c9124cc
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cmd/go/internal/load/pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -2306,7 +2306,7 @@ func (p *Package) setBuildInfo(ctx context.Context, autoVCS bool) {
}
if mi.Replace != nil {
dm.Replace = debugModFromModinfo(mi.Replace)
} else if mi.Version != "" {
} else if mi.Version != "" && cfg.BuildMod != "vendor" {
dm.Sum = modfetch.Sum(ctx, module.Version{Path: mi.Path, Version: mi.Version})
}
return dm
Expand Down
32 changes: 32 additions & 0 deletions src/cmd/go/testdata/script/mod_gomodcache_vendor.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This test verifies that GOMODCACHE does not affect whether checksums are embedded
# with vendored files.
# See issue #46400
[short] skip 'builds and links a binary twice'
go mod tidy
go mod vendor

go build -mod=vendor
go version -m example$GOEXE
cp stdout version-m.txt

env GOMODCACHE=$WORK${/}modcache
go build -mod=vendor
go version -m example$GOEXE
cmp stdout version-m.txt

-- go.mod --
module example
go 1.22
require rsc.io/sampler v1.3.0

-- main.go --
package main

import (
"fmt"
"rsc.io/sampler"
)

func main() {
fmt.Println(sampler.Hello())
}

0 comments on commit c9124cc

Please sign in to comment.