Skip to content

Commit

Permalink
cmd/go: avoid duplicate errors in module load
Browse files Browse the repository at this point in the history
Just a missing base.ExitIfErrors.

Fixes #46160.

Change-Id: I41949b0b7b036da94ba269220951677585d3f8e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/498122
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
  • Loading branch information
rsc authored and gopherbot committed May 25, 2023
1 parent e8c6003 commit 4c028ed
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/cmd/go/internal/modload/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ func loadFromRoots(ctx context.Context, params loaderParams) *loader {
ld.errorf("go: %v\n", err)
}
}
base.ExitIfErrors() // or we will report them again

for {
ld.reset()
Expand Down
5 changes: 2 additions & 3 deletions src/cmd/go/testdata/script/mod_go_version.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
env GO111MODULE=on
env TESTGO_VERSION=go1.21

# TODO(rsc): go list prints the error twice. Why?
! go list
stderr '^go: sub@v1.0.0: sub requires go 1.999 \(running go 1.21; go.mod sets go 1.1\)$'
stderr -count=1 '^go: sub@v1.0.0: sub requires go 1.999 \(running go 1.21; go.mod sets go 1.1\)$'
! go build sub
stderr '^go: sub@v1.0.0: sub requires go 1.999 \(running go 1.21; go.mod sets go 1.1\)$'
stderr -count=1 '^go: sub@v1.0.0: sub requires go 1.999 \(running go 1.21; go.mod sets go 1.1\)$'

-- go.mod --
module m
Expand Down
3 changes: 1 addition & 2 deletions src/cmd/go/testdata/script/mod_tidy_compat_implicit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ stdout '^example.net/lazy v0.1.0$'
go mod edit -go=1.16
! go list -deps -test -f $MODFMT ./...

# TODO(#46160): -count=1 instead of -count=2.
stderr -count=2 '^go: example\.net/lazy@v0\.1\.0 requires\n\texample\.com/retract/incompatible@v1\.0\.0: missing go\.sum entry for go\.mod file; to add it:\n\tgo mod download example\.com/retract/incompatible$'
stderr -count=1 '^go: example\.net/lazy@v0\.1\.0 requires\n\texample\.com/retract/incompatible@v1\.0\.0: missing go\.sum entry for go\.mod file; to add it:\n\tgo mod download example\.com/retract/incompatible$'


# If we combine a Go 1.16 go.sum file...
Expand Down
3 changes: 1 addition & 2 deletions src/cmd/go/testdata/script/mod_tidy_compat_incompatible.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ cmp go.mod go.mod.orig

go mod edit -go=1.16
! go list -f $MODFMT -deps ./...
# TODO(#46160): -count=1 instead of -count=2.
stderr -count=2 '^go: example\.net/lazy@v0\.1\.0 requires\n\texample\.net/requireincompatible@v0\.1\.0 requires\n\texample\.com/retract/incompatible@v2\.0\.0\+incompatible: missing go.sum entry for go.mod file; to add it:\n\tgo mod download example.com/retract/incompatible$'
stderr -count=1 '^go: example\.net/lazy@v0\.1\.0 requires\n\texample\.net/requireincompatible@v0\.1\.0 requires\n\texample\.com/retract/incompatible@v2\.0\.0\+incompatible: missing go.sum entry for go.mod file; to add it:\n\tgo mod download example.com/retract/incompatible$'


# There are two ways for the module author to bring the two into alignment.
Expand Down
3 changes: 1 addition & 2 deletions src/cmd/go/testdata/script/mod_tidy_compat_irrelevant.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ cmp stdout out-117.txt

go mod edit -go=1.16
! go list -deps -test -f $MODFMT all
# TODO(#46160): -count=1 instead of -count=2.
stderr -count=2 '^go: example.net/lazy@v0.1.0 requires\n\texample.com/retract/incompatible@v1.0.0: missing go.sum entry for go.mod file; to add it:\n\tgo mod download example.com/retract/incompatible$'
stderr -count=1 '^go: example.net/lazy@v0.1.0 requires\n\texample.com/retract/incompatible@v1.0.0: missing go.sum entry for go.mod file; to add it:\n\tgo mod download example.com/retract/incompatible$'


-- go.mod --
Expand Down

0 comments on commit 4c028ed

Please sign in to comment.