1
0
mirror of https://github.com/golang/go synced 2024-11-26 04:07:59 -07:00

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 <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
Bryan C. Mills 2021-04-14 10:16:51 -04:00
parent 72483de87a
commit c98026c104
2 changed files with 16 additions and 1 deletions

View File

@ -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"
}

View File

@ -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