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

For #51196.
This commit is contained in:
uji 2022-02-26 22:41:01 +09:00
parent a064a4f29a
commit 8fd1a77adf
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