From bf97c99b62fe7d6652cc8c807dbc91998d488a01 Mon Sep 17 00:00:00 2001 From: uji Date: Sat, 26 Feb 2022 13:58:54 +0000 Subject: [PATCH] cmd/go: clarify error from 'go install' when arguments have mismatched versions and paths Fixes #51196. Change-Id: I0ee4d8234f11e4f3b71b81546518647e07fafd7d GitHub-Last-Rev: 8fd1a77adff982dd00385c5b25a4e0cdf3e2e220 GitHub-Pull-Request: golang/go#51373 Reviewed-on: https://go-review.googlesource.com/c/go/+/388154 Trust: Dmitri Shuralyov Reviewed-by: Bryan Mills Run-TryBot: Bryan Mills TryBot-Result: Gopher Robot Trust: Than McIntosh Reviewed-by: Than McIntosh --- src/cmd/go/internal/load/pkg.go | 2 +- src/cmd/go/testdata/script/mod_install_pkg_version.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go index d68f43a7c98..fdc00f95dca 100644 --- a/src/cmd/go/internal/load/pkg.go +++ b/src/cmd/go/internal/load/pkg.go @@ -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 { diff --git a/src/cmd/go/testdata/script/mod_install_pkg_version.txt b/src/cmd/go/testdata/script/mod_install_pkg_version.txt index 14153b8e9ec..e3f59fc1528 100644 --- a/src/cmd/go/testdata/script/mod_install_pkg_version.txt +++ b/src/cmd/go/testdata/script/mod_install_pkg_version.txt @@ -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