1
0
mirror of https://github.com/golang/go synced 2024-11-23 17:50:06 -07:00

cmd/go: clarify error from 'go install' when arguments have mismatched versions and paths

Fixes #51196.

Change-Id: I0ee4d8234f11e4f3b71b81546518647e07fafd7d
GitHub-Last-Rev: 8fd1a77adf
GitHub-Pull-Request: golang/go#51373
Reviewed-on: https://go-review.googlesource.com/c/go/+/388154
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Than McIntosh <thanm@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
uji 2022-02-26 13:58:54 +00:00 committed by Bryan Mills
parent e79c39f004
commit bf97c99b62
2 changed files with 2 additions and 2 deletions

View File

@ -3001,7 +3001,7 @@ func PackagesAndErrorsOutsideModule(ctx context.Context, opts PackageOpts, args
patterns := make([]string, len(args))
for i, arg := range args {
if !strings.HasSuffix(arg, "@"+version) {
return nil, fmt.Errorf("%s: all arguments must have the same version (@%s)", arg, version)
return nil, fmt.Errorf("%s: all arguments must refer to packages in the same module at the same version (@%s)", arg, version)
}
p := arg[:len(arg)-len(version)-1]
switch {

View File

@ -106,7 +106,7 @@ stdout '^example.com/cmd v1.0.0$'
env GO111MODULE=auto
! go install example.com/cmd/a@v1.0.0 example.com/cmd/b@latest
stderr '^go: example.com/cmd/b@latest: all arguments must have the same version \(@v1.0.0\)$'
stderr '^go: example.com/cmd/b@latest: all arguments must refer to packages in the same module at the same version \(@v1.0.0\)$'
# 'go install pkg@version' should report an error if the arguments are in