-
Notifications
You must be signed in to change notification settings - Fork 17.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/go: reset modfetch state between modules in go work sync
go work sync resets the state in the modload package before each iteration where it updates the workspace modules' go.mod files. But before this change it wasn't resetting the global state in the modfetch package. This is necessary because the modfetch package keeps track of the sums that will be written to go.sum. Further, the fetch caches will update information about which modules are used when fetching packages, and so those caches need to be cleared between each workspace module. Thanks bcmills for helping me debug! Fixes #50038 Change-Id: I5679c18a80feb7c5194c4a5f7e7129c7d198ef7b Reviewed-on: https://go-review.googlesource.com/c/go/+/376655 Trust: Michael Matloob <matloob@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
- Loading branch information
Showing
4 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Test that the sum file data state is properly reset between modules in | ||
# go work sync so that the sum file that's written is correct. | ||
# Exercises the fix to #50038. | ||
|
||
cp b/go.sum b/go.sum.want | ||
|
||
# As a sanity check, verify b/go.sum is tidy. | ||
cd b | ||
go mod tidy | ||
cd .. | ||
cmp b/go.sum b/go.sum.want | ||
|
||
# Run go work sync and verify it doesn't change b/go.sum. | ||
go work sync | ||
cmp b/go.sum b/go.sum.want | ||
|
||
-- b/go.sum -- | ||
rsc.io/quote v1.0.0 h1:kQ3IZQzPTiDJxSZI98YaWgxFEhlNdYASHvh+MplbViw= | ||
rsc.io/quote v1.0.0/go.mod h1:v83Ri/njykPcgJltBc/gEkJTmjTsNgtO1Y7vyIK1CQA= | ||
-- go.work -- | ||
go 1.18 | ||
use ( | ||
./a | ||
./b | ||
) | ||
replace example.com/c => ./c | ||
-- a/go.mod -- | ||
module example.com/a | ||
go 1.18 | ||
require rsc.io/fortune v1.0.0 | ||
-- a/a.go -- | ||
package a | ||
import "rsc.io/fortune" | ||
-- b/go.mod -- | ||
module example.com/b | ||
go 1.18 | ||
require rsc.io/quote v1.0.0 | ||
-- b/b.go -- | ||
package b | ||
import _ "rsc.io/quote" |