From: Bryan C. Mills Date: Wed, 14 Apr 2021 14:16:51 +0000 (-0400) Subject: cmd/go/internal/modload: fix truncated error message from goModDirtyError X-Git-Tag: go1.17beta1~658 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=c98026c104;p=gostls13.git cmd/go/internal/modload: fix truncated error message from goModDirtyError The 'go mod tidy' hint was truncated due to a typo in CL 293689, and that particular case was not covered by any existing test. Updates #36460 Updates #40775 Change-Id: Ib6fa872a9dfdafc4e9a112e8add2ff5aecd2dbd0 Reviewed-on: https://go-review.googlesource.com/c/go/+/310089 Trust: Bryan C. Mills Run-TryBot: Bryan C. Mills Reviewed-by: David Chase TryBot-Result: Go Bot --- diff --git a/src/cmd/go/internal/modload/init.go b/src/cmd/go/internal/modload/init.go index 777b63841f..120afef4ff 100644 --- a/src/cmd/go/internal/modload/init.go +++ b/src/cmd/go/internal/modload/init.go @@ -354,7 +354,7 @@ func (goModDirtyError) Error() string { return fmt.Sprintf("updates to go.mod needed, disabled by -mod=%v; to update it:\n\tgo mod tidy", cfg.BuildMod) } if cfg.BuildModReason != "" { - return fmt.Sprintf("updates to go.mod needed, disabled by -mod=%s\n\t(%s)\n\tto update it:\n\t", cfg.BuildMod, cfg.BuildModReason) + return fmt.Sprintf("updates to go.mod needed, disabled by -mod=%s\n\t(%s)\n\tto update it:\n\tgo mod tidy", cfg.BuildMod, cfg.BuildModReason) } return "updates to go.mod needed; to update it:\n\tgo mod tidy" } diff --git a/src/cmd/go/testdata/script/mod_require_exclude.txt b/src/cmd/go/testdata/script/mod_require_exclude.txt index 5b6143da42..0946dbf0bb 100644 --- a/src/cmd/go/testdata/script/mod_require_exclude.txt +++ b/src/cmd/go/testdata/script/mod_require_exclude.txt @@ -17,6 +17,17 @@ stderr '^go: updates to go.mod needed, disabled by -mod=vendor; to update it:\n\ ! stdout '^rsc.io/sampler v1.99.99' cmp go.mod go.mod.orig +# The failure message should be clear when -mod=vendor is implicit. + +go mod edit -go=1.14 +! go list -m rsc.io/sampler +stderr '^go: ignoring requirement on excluded version rsc.io/sampler v1\.99\.99$' +stderr '^go: updates to go.mod needed, disabled by -mod=vendor\n\t\(Go version in go.mod is at least 1.14 and vendor directory exists\.\)\n\tto update it:\n\tgo mod tidy$' +! stdout '^rsc.io/sampler v1.99.99' +go mod edit -go=1.13 +cmp go.mod go.mod.orig + + # With the selected version excluded, commands that load only modules should # drop the excluded module. @@ -58,7 +69,11 @@ module x go 1.13 exclude rsc.io/sampler v1.99.99 + require rsc.io/sampler v1.99.99 +-- vendor/modules.txt -- +# rsc.io/sampler v1.99.99 +## explicit -- go.moddrop -- module x