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

696 views
Skip to first unread message

Gerrit Bot (Gerrit)

unread,
Feb 26, 2022, 8:59:02 AM2/26/22
to goph...@pubsubhelper.golang.org, Daichi Ujimoto, golang-co...@googlegroups.com

Gerrit Bot has uploaded this change for review.

View Change

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
---
M src/cmd/go/internal/load/pkg.go
M src/cmd/go/testdata/script/mod_install_pkg_version.txt
2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go
index d68f43a..fdc00f9 100644
--- a/src/cmd/go/internal/load/pkg.go
+++ b/src/cmd/go/internal/load/pkg.go
@@ -3001,7 +3001,7 @@
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 14153b8..e3f59fc 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 @@
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

To view, visit change 388154. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I0ee4d8234f11e4f3b71b81546518647e07fafd7d
Gerrit-Change-Number: 388154
Gerrit-PatchSet: 1
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-CC: Daichi Ujimoto <uji...@gmail.com>
Gerrit-MessageType: newchange

Dmitri Shuralyov (Gerrit)

unread,
Feb 26, 2022, 10:52:26 AM2/26/22
to Gerrit Bot, Daichi Ujimoto, goph...@pubsubhelper.golang.org, Dmitri Shuralyov, Bryan Mills, golang-co...@googlegroups.com

Patch set 1:Run-TryBot +1Trust +1

View Change

1 comment:

To view, visit change 388154. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I0ee4d8234f11e4f3b71b81546518647e07fafd7d
Gerrit-Change-Number: 388154
Gerrit-PatchSet: 1
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-Reviewer: Dmitri Shuralyov <dmit...@golang.org>
Gerrit-CC: Bryan Mills <bcm...@google.com>
Gerrit-CC: Daichi Ujimoto <uji...@gmail.com>
Gerrit-Comment-Date: Sat, 26 Feb 2022 15:52:20 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

Bryan Mills (Gerrit)

unread,
Feb 28, 2022, 2:28:18 PM2/28/22
to Gerrit Bot, Daichi Ujimoto, goph...@pubsubhelper.golang.org, Bryan Mills, Gopher Robot, Dmitri Shuralyov, golang-co...@googlegroups.com

Patch set 1:Run-TryBot +1Code-Review +2

View Change

1 comment:

To view, visit change 388154. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I0ee4d8234f11e4f3b71b81546518647e07fafd7d
Gerrit-Change-Number: 388154
Gerrit-PatchSet: 1
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
Gerrit-Reviewer: Dmitri Shuralyov <dmit...@golang.org>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-CC: Daichi Ujimoto <uji...@gmail.com>
Gerrit-Comment-Date: Mon, 28 Feb 2022 19:28:14 +0000

Bryan Mills (Gerrit)

unread,
Mar 4, 2022, 3:37:16 PM3/4/22
to Bryan Mills, Gerrit Bot, daichi ujimoto, goph...@pubsubhelper.golang.org, Gopher Robot, Dmitri Shuralyov, golang-co...@googlegroups.com

Patch set 2:Run-TryBot +1Code-Review +2

View Change

    To view, visit change 388154. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I0ee4d8234f11e4f3b71b81546518647e07fafd7d
    Gerrit-Change-Number: 388154
    Gerrit-PatchSet: 2
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
    Gerrit-Reviewer: Dmitri Shuralyov <dmit...@golang.org>
    Gerrit-Reviewer: Gopher Robot <go...@golang.org>
    Gerrit-CC: daichi ujimoto <uji...@gmail.com>
    Gerrit-Comment-Date: Fri, 04 Mar 2022 20:37:13 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    Gerrit-MessageType: comment

    Than McIntosh (Gerrit)

    unread,
    Mar 4, 2022, 4:04:50 PM3/4/22
    to Bryan Mills, Gerrit Bot, daichi ujimoto, goph...@pubsubhelper.golang.org, Gopher Robot, Dmitri Shuralyov, golang-co...@googlegroups.com

    Attention is currently required from: Bryan Mills.

    Patch set 2:Trust +1

    View Change

      To view, visit change 388154. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I0ee4d8234f11e4f3b71b81546518647e07fafd7d
      Gerrit-Change-Number: 388154
      Gerrit-PatchSet: 2
      Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
      Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
      Gerrit-Reviewer: Dmitri Shuralyov <dmit...@golang.org>
      Gerrit-Reviewer: Gopher Robot <go...@golang.org>
      Gerrit-Reviewer: Than McIntosh <th...@google.com>
      Gerrit-CC: daichi ujimoto <uji...@gmail.com>
      Gerrit-Attention: Bryan Mills <bcm...@google.com>
      Gerrit-Comment-Date: Fri, 04 Mar 2022 21:04:47 +0000

      Than McIntosh (Gerrit)

      unread,
      Mar 4, 2022, 4:05:20 PM3/4/22
      to Bryan Mills, Gerrit Bot, daichi ujimoto, goph...@pubsubhelper.golang.org, Gopher Robot, Dmitri Shuralyov, golang-co...@googlegroups.com

      Attention is currently required from: Bryan Mills.

      Patch set 2:Code-Review +2

      View Change

        To view, visit change 388154. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I0ee4d8234f11e4f3b71b81546518647e07fafd7d
        Gerrit-Change-Number: 388154
        Gerrit-PatchSet: 2
        Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
        Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
        Gerrit-Reviewer: Dmitri Shuralyov <dmit...@golang.org>
        Gerrit-Reviewer: Gopher Robot <go...@golang.org>
        Gerrit-Reviewer: Than McIntosh <th...@google.com>
        Gerrit-CC: daichi ujimoto <uji...@gmail.com>
        Gerrit-Attention: Bryan Mills <bcm...@google.com>
        Gerrit-Comment-Date: Fri, 04 Mar 2022 21:05:17 +0000

        Bryan Mills (Gerrit)

        unread,
        Mar 4, 2022, 4:06:08 PM3/4/22
        to Bryan Mills, Gerrit Bot, daichi ujimoto, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Than McIntosh, Gopher Robot, Dmitri Shuralyov, golang-co...@googlegroups.com

        Bryan Mills submitted this change.

        View Change


        Approvals: Bryan Mills: Looks good to me, approved; Run TryBots Than McIntosh: Looks good to me, approved; Trusted Dmitri Shuralyov: Trusted Gopher Robot: TryBots succeeded
        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 <dmit...@golang.org>
        Reviewed-by: Bryan Mills <bcm...@google.com>
        Run-TryBot: Bryan Mills <bcm...@google.com>
        TryBot-Result: Gopher Robot <go...@golang.org>
        Trust: Than McIntosh <th...@google.com>
        Reviewed-by: Than McIntosh <th...@google.com>

        ---
        M src/cmd/go/internal/load/pkg.go
        M src/cmd/go/testdata/script/mod_install_pkg_version.txt
        2 files changed, 22 insertions(+), 2 deletions(-)

        diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go
        index d68f43a..fdc00f9 100644
        --- a/src/cmd/go/internal/load/pkg.go
        +++ b/src/cmd/go/internal/load/pkg.go
        @@ -3001,7 +3001,7 @@
        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 14153b8..e3f59fc 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 @@
        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

        To view, visit change 388154. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I0ee4d8234f11e4f3b71b81546518647e07fafd7d
        Gerrit-Change-Number: 388154
        Gerrit-PatchSet: 3
        Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
        Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
        Gerrit-Reviewer: Dmitri Shuralyov <dmit...@golang.org>
        Gerrit-Reviewer: Gopher Robot <go...@golang.org>
        Gerrit-Reviewer: Than McIntosh <th...@google.com>
        Gerrit-CC: daichi ujimoto <uji...@gmail.com>
        Gerrit-MessageType: merged
        Reply all
        Reply to author
        Forward
        0 new messages