[go] cmd/go/internal/modload: improve error message for failing to read module listed in go.work

135 views
Skip to first unread message

Gerrit Bot (Gerrit)

unread,
Oct 5, 2022, 5:40:45 AM10/5/22
to goph...@pubsubhelper.golang.org, Zeke Lu, golang-co...@googlegroups.com

Gerrit Bot has uploaded this change for review.

View Change

cmd/go/internal/modload: improve error message for failing to read module listed in go.work

Run "go build ./x" in this workspace:

-- go.work --
use ./y
-- x/go.mod --
module x

go 1.19
-- x/m.go --
package m

It fails with: "go: open /tmp/foo/y/go.mod: no such file or directory".
It's unclear where the name "y" comes from.
This change will emit error like: "go: cannot load module y named in
go.work file: open /tmp/foo/y/go.mod: no such file or directory"

It would be better to add the content of the use line to the error.
But we don't have that info when the error happens. So we just use the
base name of the module directory as the module name.

Fixes #55952.

Change-Id: Ia45dd915e3fbd6e33340f352b3d6235c6c31190b
GitHub-Last-Rev: 51236225618acef05b1b351891cb2e17db292d71
GitHub-Pull-Request: golang/go#56050
---
M src/cmd/go/internal/modload/init.go
A src/cmd/go/testdata/script/work_use_issue55952.txt
2 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/src/cmd/go/internal/modload/init.go b/src/cmd/go/internal/modload/init.go
index 7da2beb..260bc23 100644
--- a/src/cmd/go/internal/modload/init.go
+++ b/src/cmd/go/internal/modload/init.go
@@ -718,7 +718,11 @@
var fixed bool
data, f, err := ReadModFile(gomod, fixVersion(ctx, &fixed))
if err != nil {
- base.Fatalf("go: %v", err)
+ if inWorkspaceMode() {
+ base.Fatalf("go: cannot load module %s named in go.work file: %v", filepath.Base(modroot), err)
+ } else {
+ base.Fatalf("go: %v", err)
+ }
}

modFiles = append(modFiles, f)
diff --git a/src/cmd/go/testdata/script/work_use_issue55952.txt b/src/cmd/go/testdata/script/work_use_issue55952.txt
new file mode 100644
index 0000000..9d7bd0f
--- /dev/null
+++ b/src/cmd/go/testdata/script/work_use_issue55952.txt
@@ -0,0 +1,11 @@
+! go list .
+stderr '^go: cannot load module y named in go\.work file: open .+go\.mod: no such file or directory$'
+
+-- go.work --
+use ./y
+-- x/go.mod --
+module x
+
+go 1.19
+-- x/m.go --
+package m

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

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Ia45dd915e3fbd6e33340f352b3d6235c6c31190b
Gerrit-Change-Number: 438147
Gerrit-PatchSet: 1
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-CC: Zeke Lu <lvz...@gmail.com>
Gerrit-MessageType: newchange

Gerrit Bot (Gerrit)

unread,
Oct 5, 2022, 5:45:50 AM10/5/22
to Zeke Lu, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Gerrit Bot uploaded patch set #2 to this change.

View Change

cmd/go/internal/modload: improve error message for failing to read module listed in go.work

Run "go build ./x" in this workspace:

-- go.work --
use ./y
-- x/go.mod --
module x

go 1.19
-- x/m.go --
package m

It fails with: "go: open /tmp/foo/y/go.mod: no such file or directory".
It's unclear where the name "y" comes from.
This CL makes it emit error like: "go: cannot load module y named in

go.work file: open /tmp/foo/y/go.mod: no such file or directory"

It would be better to add the content of the use line to the error.
But we don't have that info when the error happens. So we just use the
base name of the module directory as the module name.

Fixes #55952.

Change-Id: Ia45dd915e3fbd6e33340f352b3d6235c6c31190b
GitHub-Last-Rev: 51236225618acef05b1b351891cb2e17db292d71
GitHub-Pull-Request: golang/go#56050
---
M src/cmd/go/internal/modload/init.go
A src/cmd/go/testdata/script/work_use_issue55952.txt
2 files changed, 49 insertions(+), 1 deletion(-)

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

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Ia45dd915e3fbd6e33340f352b3d6235c6c31190b
Gerrit-Change-Number: 438147
Gerrit-PatchSet: 2
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-CC: Zeke Lu <lvz...@gmail.com>
Gerrit-MessageType: newpatchset

Alan Donovan (Gerrit)

unread,
Oct 5, 2022, 8:31:38 AM10/5/22
to Gerrit Bot, Zeke Lu, goph...@pubsubhelper.golang.org, Bryan Mills, Michael Matloob, Russ Cox, Ian Lance Taylor, Gopher Robot, golang-co...@googlegroups.com

Attention is currently required from: Bryan Mills, Michael Matloob.

Patch set 2:Code-Review +2

View Change

1 comment:

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

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Ia45dd915e3fbd6e33340f352b3d6235c6c31190b
Gerrit-Change-Number: 438147
Gerrit-PatchSet: 2
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
Gerrit-CC: Russ Cox <r...@golang.org>
Gerrit-CC: Zeke Lu <lvz...@gmail.com>
Gerrit-Attention: Bryan Mills <bcm...@google.com>
Gerrit-Attention: Michael Matloob <mat...@golang.org>
Gerrit-Comment-Date: Wed, 05 Oct 2022 12:31:34 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

Bryan Mills (Gerrit)

unread,
Oct 5, 2022, 11:00:17 AM10/5/22
to Gerrit Bot, Zeke Lu, goph...@pubsubhelper.golang.org, Alan Donovan, Bryan Mills, Michael Matloob, Russ Cox, Ian Lance Taylor, Gopher Robot, golang-co...@googlegroups.com

Attention is currently required from: Michael Matloob.

View Change

1 comment:

  • File src/cmd/go/internal/modload/init.go:

    • Patch Set #2, Line 722: filepath.Base(modroot)

      I don't think the call to `filepath.Base` is appropriate here — what if my `go.work` file has a bunch of modules that all end with the same element?

      ```
      use (
      ./x/foo
      ./y/foo
      ./z/foo
      )
      ```

      Plus, usually when we use the word "module" we follow it with a module path, but nothing requires that the final element of the directory path has anything to do with the module path contained in that directory. 😅

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

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Ia45dd915e3fbd6e33340f352b3d6235c6c31190b
Gerrit-Change-Number: 438147
Gerrit-PatchSet: 2
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
Gerrit-CC: Russ Cox <r...@golang.org>
Gerrit-CC: Zeke Lu <lvz...@gmail.com>
Gerrit-Attention: Michael Matloob <mat...@golang.org>
Gerrit-Comment-Date: Wed, 05 Oct 2022 15:00:10 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment

Zeke Lu (Gerrit)

unread,
Oct 5, 2022, 11:36:26 AM10/5/22
to Gerrit Bot, goph...@pubsubhelper.golang.org, Alan Donovan, Bryan Mills, Michael Matloob, Russ Cox, Ian Lance Taylor, Gopher Robot, golang-co...@googlegroups.com

Attention is currently required from: Bryan Mills, Michael Matloob.

View Change

1 comment:

  • File src/cmd/go/internal/modload/init.go:

    • I don't think the call to `filepath.Base` is appropriate here — what if my `go. […]

      Understood. How about removing this information from the message? Like this:

      ```
      base.Fatalf("go: cannot load module added to go.work file: %v", err)
      ```

      We can try to get the content of the `use` line here. But it could make the code complicated and it seems that it does not worth it.

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

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Ia45dd915e3fbd6e33340f352b3d6235c6c31190b
Gerrit-Change-Number: 438147
Gerrit-PatchSet: 2
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
Gerrit-CC: Russ Cox <r...@golang.org>
Gerrit-CC: Zeke Lu <lvz...@gmail.com>
Gerrit-Attention: Bryan Mills <bcm...@google.com>
Gerrit-Attention: Michael Matloob <mat...@golang.org>
Gerrit-Comment-Date: Wed, 05 Oct 2022 15:36:18 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Bryan Mills <bcm...@google.com>
Gerrit-MessageType: comment

Bryan Mills (Gerrit)

unread,
Oct 5, 2022, 11:40:44 AM10/5/22
to Gerrit Bot, Zeke Lu, goph...@pubsubhelper.golang.org, Alan Donovan, Bryan Mills, Michael Matloob, Russ Cox, Ian Lance Taylor, Gopher Robot, golang-co...@googlegroups.com

Attention is currently required from: Michael Matloob, Zeke Lu.

View Change

1 comment:

  • File src/cmd/go/internal/modload/init.go:

    • Understood. How about removing this information from the message? Like this: […]

      That sounds good. Thanks!

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

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Ia45dd915e3fbd6e33340f352b3d6235c6c31190b
Gerrit-Change-Number: 438147
Gerrit-PatchSet: 2
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
Gerrit-CC: Russ Cox <r...@golang.org>
Gerrit-CC: Zeke Lu <lvz...@gmail.com>
Gerrit-Attention: Zeke Lu <lvz...@gmail.com>
Gerrit-Attention: Michael Matloob <mat...@golang.org>
Gerrit-Comment-Date: Wed, 05 Oct 2022 15:40:36 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Bryan Mills <bcm...@google.com>
Comment-In-Reply-To: Zeke Lu <lvz...@gmail.com>
Gerrit-MessageType: comment

Gerrit Bot (Gerrit)

unread,
Oct 5, 2022, 12:16:19 PM10/5/22
to Zeke Lu, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Attention is currently required from: Michael Matloob, Zeke Lu.

Gerrit Bot uploaded patch set #3 to this change.

View Change

cmd/go/internal/modload: improve error message for failing to read module listed in go.work

Run "go build ./x" in this workspace:

-- go.work --
use ./y
-- x/go.mod --
module x

go 1.19
-- x/m.go --
package m

It fails with: "go: open /tmp/foo/y/go.mod: no such file or directory".
It's unclear where the name "y" comes from.
This change will emit error like: "go: cannot load module added to
go.work file: open /tmp/foo/y/go.mod: no such file or directory"

Fixes #55952.

Change-Id: Ia45dd915e3fbd6e33340f352b3d6235c6c31190b
GitHub-Last-Rev: abd77415d8028df94d5f68254f028c7fb1b5066e

GitHub-Pull-Request: golang/go#56050
---
M src/cmd/go/internal/modload/init.go
A src/cmd/go/testdata/script/work_use_issue55952.txt
2 files changed, 45 insertions(+), 1 deletion(-)

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

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Ia45dd915e3fbd6e33340f352b3d6235c6c31190b
Gerrit-Change-Number: 438147
Gerrit-PatchSet: 3
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
Gerrit-CC: Russ Cox <r...@golang.org>
Gerrit-CC: Zeke Lu <lvz...@gmail.com>
Gerrit-Attention: Zeke Lu <lvz...@gmail.com>
Gerrit-Attention: Michael Matloob <mat...@golang.org>
Gerrit-MessageType: newpatchset

Zeke Lu (Gerrit)

unread,
Oct 5, 2022, 12:17:40 PM10/5/22
to Gerrit Bot, goph...@pubsubhelper.golang.org, Alan Donovan, Bryan Mills, Michael Matloob, Russ Cox, Ian Lance Taylor, Gopher Robot, golang-co...@googlegroups.com

Attention is currently required from: Bryan Mills, Michael Matloob.

View Change

1 comment:

  • File src/cmd/go/internal/modload/init.go:

    • That sounds good. […]

      Done!
      Thank you Alan for the idea! And thank you Bryan for your review! ❤️

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

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Ia45dd915e3fbd6e33340f352b3d6235c6c31190b
Gerrit-Change-Number: 438147
Gerrit-PatchSet: 3
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
Gerrit-CC: Russ Cox <r...@golang.org>
Gerrit-CC: Zeke Lu <lvz...@gmail.com>
Gerrit-Attention: Bryan Mills <bcm...@google.com>
Gerrit-Attention: Michael Matloob <mat...@golang.org>
Gerrit-Comment-Date: Wed, 05 Oct 2022 16:17:23 +0000

Bryan Mills (Gerrit)

unread,
Oct 6, 2022, 1:42:02 PM10/6/22
to Gerrit Bot, Zeke Lu, goph...@pubsubhelper.golang.org, Bryan Mills, Alan Donovan, Michael Matloob, Russ Cox, Ian Lance Taylor, Gopher Robot, golang-co...@googlegroups.com

Attention is currently required from: Michael Matloob.

Patch set 3:Code-Review +2

View Change

1 comment:

  • File src/cmd/go/internal/modload/init.go:

    • Patch Set #3, Line 722: added to

      (nit) s/added to/listed in/

      (since this invocation of the `go` command is not the one adding it)

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

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Ia45dd915e3fbd6e33340f352b3d6235c6c31190b
Gerrit-Change-Number: 438147
Gerrit-PatchSet: 3
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
Gerrit-CC: Russ Cox <r...@golang.org>
Gerrit-CC: Zeke Lu <lvz...@gmail.com>
Gerrit-Attention: Michael Matloob <mat...@golang.org>
Gerrit-Comment-Date: Thu, 06 Oct 2022 17:41:57 +0000

Gerrit Bot (Gerrit)

unread,
Oct 6, 2022, 2:37:41 PM10/6/22
to Zeke Lu, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Attention is currently required from: Michael Matloob.

Gerrit Bot uploaded patch set #4 to this change.

View Change

cmd/go/internal/modload: improve error message for failing to read module listed in go.work

Run "go build ./x" in this workspace:

-- go.work --
use ./y
-- x/go.mod --
module x

go 1.19
-- x/m.go --
package m

It fails with: "go: open /tmp/foo/y/go.mod: no such file or directory".
It's unclear where the name "y" comes from.
This change will emit error like: "go: cannot load module listed in

go.work file: open /tmp/foo/y/go.mod: no such file or directory"

Fixes #55952.

Change-Id: Ia45dd915e3fbd6e33340f352b3d6235c6c31190b
GitHub-Last-Rev: ec97646f2242297621dc6e4654a500fa5cf9be10

GitHub-Pull-Request: golang/go#56050
---
M src/cmd/go/internal/modload/init.go
A src/cmd/go/testdata/script/work_use_issue55952.txt
2 files changed, 45 insertions(+), 1 deletion(-)

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

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Ia45dd915e3fbd6e33340f352b3d6235c6c31190b
Gerrit-Change-Number: 438147
Gerrit-PatchSet: 4
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
Gerrit-CC: Russ Cox <r...@golang.org>
Gerrit-CC: Zeke Lu <lvz...@gmail.com>
Gerrit-Attention: Michael Matloob <mat...@golang.org>
Gerrit-MessageType: newpatchset

Zeke Lu (Gerrit)

unread,
Oct 6, 2022, 2:40:44 PM10/6/22
to Gerrit Bot, goph...@pubsubhelper.golang.org, Bryan Mills, Alan Donovan, Michael Matloob, Russ Cox, Ian Lance Taylor, Gopher Robot, golang-co...@googlegroups.com

Attention is currently required from: Michael Matloob.

View Change

1 comment:

  • File src/cmd/go/internal/modload/init.go:

    • (nit) s/added to/listed in/ […]

      Done

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

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Ia45dd915e3fbd6e33340f352b3d6235c6c31190b
Gerrit-Change-Number: 438147
Gerrit-PatchSet: 4
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
Gerrit-CC: Russ Cox <r...@golang.org>
Gerrit-CC: Zeke Lu <lvz...@gmail.com>
Gerrit-Attention: Michael Matloob <mat...@golang.org>
Gerrit-Comment-Date: Thu, 06 Oct 2022 18:40:35 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Bryan Mills <bcm...@google.com>
Gerrit-MessageType: comment

Bryan Mills (Gerrit)

unread,
Oct 6, 2022, 3:01:26 PM10/6/22
to Gerrit Bot, Zeke Lu, goph...@pubsubhelper.golang.org, Bryan Mills, Alan Donovan, Michael Matloob, Russ Cox, Ian Lance Taylor, Gopher Robot, golang-co...@googlegroups.com

Attention is currently required from: Michael Matloob.

Patch set 4:Run-TryBot +1Auto-Submit +1Code-Review +2

View Change

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

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ia45dd915e3fbd6e33340f352b3d6235c6c31190b
    Gerrit-Change-Number: 438147
    Gerrit-PatchSet: 4
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
    Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
    Gerrit-CC: Russ Cox <r...@golang.org>
    Gerrit-CC: Zeke Lu <lvz...@gmail.com>
    Gerrit-Attention: Michael Matloob <mat...@golang.org>
    Gerrit-Comment-Date: Thu, 06 Oct 2022 19:01:18 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    Gerrit-MessageType: comment

    Gerrit Bot (Gerrit)

    unread,
    Oct 6, 2022, 8:49:21 PM10/6/22
    to Zeke Lu, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

    Attention is currently required from: Bryan Mills, Michael Matloob.

    Gerrit Bot uploaded patch set #5 to this change.

    View Change

    The following approvals got outdated and were removed: Auto-Submit+1 by Bryan Mills, Run-TryBot+1 by Bryan Mills, TryBot-Result-1 by Gopher Robot

    cmd/go/internal/modload: improve error message for failing to read module listed in go.work

    Run "go build ./x" in this workspace:

    -- go.work --
    use ./y
    -- x/go.mod --
    module x

    go 1.19
    -- x/m.go --
    package m

    It fails with: "go: open /tmp/foo/y/go.mod: no such file or directory".
    It's unclear where the name "y" comes from.
    This change will emit error like: "go: cannot load module listed in
    go.work file: open /tmp/foo/y/go.mod: no such file or directory"

    Fixes #55952.

    Change-Id: Ia45dd915e3fbd6e33340f352b3d6235c6c31190b
    GitHub-Last-Rev: 410de1b4a71d07bbd5abd1482b6d55fa29f31336

    GitHub-Pull-Request: golang/go#56050
    ---
    M src/cmd/go/internal/modload/init.go
    A src/cmd/go/testdata/script/work_use_issue55952.txt
    2 files changed, 45 insertions(+), 1 deletion(-)

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

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ia45dd915e3fbd6e33340f352b3d6235c6c31190b
    Gerrit-Change-Number: 438147
    Gerrit-PatchSet: 5
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
    Gerrit-Reviewer: Gopher Robot <go...@golang.org>
    Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
    Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
    Gerrit-CC: Russ Cox <r...@golang.org>
    Gerrit-CC: Zeke Lu <lvz...@gmail.com>
    Gerrit-Attention: Bryan Mills <bcm...@google.com>

    Zeke Lu (Gerrit)

    unread,
    Oct 6, 2022, 8:56:03 PM10/6/22
    to Gerrit Bot, goph...@pubsubhelper.golang.org, Gopher Robot, Bryan Mills, Alan Donovan, Michael Matloob, Russ Cox, Ian Lance Taylor, golang-co...@googlegroups.com

    Attention is currently required from: Bryan Mills, Michael Matloob.

    View Change

    1 comment:

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

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ia45dd915e3fbd6e33340f352b3d6235c6c31190b
    Gerrit-Change-Number: 438147
    Gerrit-PatchSet: 5
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
    Gerrit-Reviewer: Gopher Robot <go...@golang.org>
    Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
    Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
    Gerrit-CC: Russ Cox <r...@golang.org>
    Gerrit-CC: Zeke Lu <lvz...@gmail.com>
    Gerrit-Attention: Bryan Mills <bcm...@google.com>
    Gerrit-Attention: Michael Matloob <mat...@golang.org>
    Gerrit-Comment-Date: Fri, 07 Oct 2022 00:55:56 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Gopher Robot <go...@golang.org>
    Gerrit-MessageType: comment

    hopehook (Gerrit)

    unread,
    Oct 6, 2022, 9:29:37 PM10/6/22
    to Gerrit Bot, Zeke Lu, goph...@pubsubhelper.golang.org, Gopher Robot, Bryan Mills, Alan Donovan, Michael Matloob, Russ Cox, Ian Lance Taylor, golang-co...@googlegroups.com

    Attention is currently required from: Bryan Mills, Michael Matloob.

    Patch set 5:Run-TryBot +1

    View Change

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

      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: Ia45dd915e3fbd6e33340f352b3d6235c6c31190b
      Gerrit-Change-Number: 438147
      Gerrit-PatchSet: 5
      Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
      Gerrit-Reviewer: Alan Donovan <adon...@google.com>
      Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
      Gerrit-Reviewer: Gopher Robot <go...@golang.org>
      Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
      Gerrit-Reviewer: hopehook <hope...@golangcn.org>
      Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
      Gerrit-CC: Russ Cox <r...@golang.org>
      Gerrit-CC: Zeke Lu <lvz...@gmail.com>
      Gerrit-Attention: Bryan Mills <bcm...@google.com>
      Gerrit-Attention: Michael Matloob <mat...@golang.org>
      Gerrit-Comment-Date: Fri, 07 Oct 2022 01:29:29 +0000

      Bryan Mills (Gerrit)

      unread,
      Oct 7, 2022, 11:59:55 AM10/7/22
      to Gerrit Bot, Zeke Lu, goph...@pubsubhelper.golang.org, Bryan Mills, Gopher Robot, hopehook, Alan Donovan, Michael Matloob, Russ Cox, Ian Lance Taylor, golang-co...@googlegroups.com

      Attention is currently required from: Michael Matloob.

      Patch set 5:Run-TryBot +1Auto-Submit +1Code-Review +2

      View Change

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

        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: Ia45dd915e3fbd6e33340f352b3d6235c6c31190b
        Gerrit-Change-Number: 438147
        Gerrit-PatchSet: 5
        Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
        Gerrit-Reviewer: Alan Donovan <adon...@google.com>
        Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
        Gerrit-Reviewer: Gopher Robot <go...@golang.org>
        Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
        Gerrit-Reviewer: hopehook <hope...@golangcn.org>
        Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
        Gerrit-CC: Russ Cox <r...@golang.org>
        Gerrit-CC: Zeke Lu <lvz...@gmail.com>
        Gerrit-Attention: Michael Matloob <mat...@golang.org>
        Gerrit-Comment-Date: Fri, 07 Oct 2022 15:59:50 +0000

        hopehook (Gerrit)

        unread,
        Oct 8, 2022, 2:08:51 AM10/8/22
        to Gerrit Bot, Zeke Lu, goph...@pubsubhelper.golang.org, Bryan Mills, Gopher Robot, Alan Donovan, Michael Matloob, Russ Cox, Ian Lance Taylor, golang-co...@googlegroups.com

        Attention is currently required from: Michael Matloob, Zeke Lu.

        View Change

        1 comment:

        • Patchset:

          • Patch Set #4:

            Fixed.

            Hi @lvz...@gmail.com. If you are ready to submit this CL, I think you should mark it as resolved.
            So this CL will be committed automatically.

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

        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: Ia45dd915e3fbd6e33340f352b3d6235c6c31190b
        Gerrit-Change-Number: 438147
        Gerrit-PatchSet: 5
        Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
        Gerrit-Reviewer: Alan Donovan <adon...@google.com>
        Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
        Gerrit-Reviewer: Gopher Robot <go...@golang.org>
        Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
        Gerrit-Reviewer: hopehook <hope...@golangcn.org>
        Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
        Gerrit-CC: Russ Cox <r...@golang.org>
        Gerrit-CC: Zeke Lu <lvz...@gmail.com>
        Gerrit-Attention: Zeke Lu <lvz...@gmail.com>
        Gerrit-Attention: Michael Matloob <mat...@golang.org>
        Gerrit-Comment-Date: Sat, 08 Oct 2022 06:08:42 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Gopher Robot <go...@golang.org>

        Zeke Lu (Gerrit)

        unread,
        Oct 8, 2022, 5:28:43 AM10/8/22
        to Gerrit Bot, goph...@pubsubhelper.golang.org, Bryan Mills, Gopher Robot, hopehook, Alan Donovan, Michael Matloob, Russ Cox, Ian Lance Taylor, golang-co...@googlegroups.com

        Attention is currently required from: Michael Matloob, hopehook.

        View Change

        1 comment:

        • Patchset:

          • Patch Set #4:

            Hi @lvz...@gmail.com. If you are ready to submit this CL, I think you should mark it as resolved. […]

            I thought I have marked it as resolved. Obviously I haven't. Thank you! I'm going to do it.

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

        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: Ia45dd915e3fbd6e33340f352b3d6235c6c31190b
        Gerrit-Change-Number: 438147
        Gerrit-PatchSet: 5
        Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
        Gerrit-Reviewer: Alan Donovan <adon...@google.com>
        Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
        Gerrit-Reviewer: Gopher Robot <go...@golang.org>
        Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
        Gerrit-Reviewer: hopehook <hope...@golangcn.org>
        Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
        Gerrit-CC: Russ Cox <r...@golang.org>
        Gerrit-CC: Zeke Lu <lvz...@gmail.com>
        Gerrit-Attention: hopehook <hope...@golangcn.org>
        Gerrit-Attention: Michael Matloob <mat...@golang.org>
        Gerrit-Comment-Date: Sat, 08 Oct 2022 09:28:35 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: hopehook <hope...@golangcn.org>

        Gopher Robot (Gerrit)

        unread,
        Oct 8, 2022, 5:29:20 AM10/8/22
        to Gerrit Bot, Zeke Lu, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Bryan Mills, hopehook, Alan Donovan, Michael Matloob, Russ Cox, Ian Lance Taylor, golang-co...@googlegroups.com

        Gopher Robot submitted this change.

        View Change


        Approvals: Bryan Mills: Looks good to me, approved; Run TryBots; Automatically submit change Gopher Robot: TryBots succeeded hopehook: Run TryBots Alan Donovan: Looks good to me, approved
        cmd/go/internal/modload: improve error message for failing to read module listed in go.work

        Run "go build ./x" in this workspace:

        -- go.work --
        use ./y
        -- x/go.mod --
        module x

        go 1.19
        -- x/m.go --
        package m

        It fails with: "go: open /tmp/foo/y/go.mod: no such file or directory".
        It's unclear where the name "y" comes from.
        This change will emit error like: "go: cannot load module listed in
        go.work file: open /tmp/foo/y/go.mod: no such file or directory"

        Fixes #55952.

        Change-Id: Ia45dd915e3fbd6e33340f352b3d6235c6c31190b
        GitHub-Last-Rev: 410de1b4a71d07bbd5abd1482b6d55fa29f31336
        GitHub-Pull-Request: golang/go#56050
        Reviewed-on: https://go-review.googlesource.com/c/go/+/438147
        Run-TryBot: hopehook <hope...@golangcn.org>
        TryBot-Result: Gopher Robot <go...@golang.org>
        Auto-Submit: Bryan Mills <bcm...@google.com>
        Reviewed-by: Bryan Mills <bcm...@google.com>
        Run-TryBot: Bryan Mills <bcm...@google.com>
        Reviewed-by: Alan Donovan <adon...@google.com>

        ---
        M src/cmd/go/internal/modload/init.go
        A src/cmd/go/testdata/script/work_use_issue55952.txt
        2 files changed, 52 insertions(+), 1 deletion(-)

        diff --git a/src/cmd/go/internal/modload/init.go b/src/cmd/go/internal/modload/init.go
        index 7da2beb..06be184 100644

        --- a/src/cmd/go/internal/modload/init.go
        +++ b/src/cmd/go/internal/modload/init.go
        @@ -718,7 +718,11 @@
        var fixed bool
        data, f, err := ReadModFile(gomod, fixVersion(ctx, &fixed))
        if err != nil {
        - base.Fatalf("go: %v", err)
        + if inWorkspaceMode() {
        +				base.Fatalf("go: cannot load module listed in go.work file: %v", err)

        + } else {
        + base.Fatalf("go: %v", err)
        + }
        }

        modFiles = append(modFiles, f)
        diff --git a/src/cmd/go/testdata/script/work_use_issue55952.txt b/src/cmd/go/testdata/script/work_use_issue55952.txt
        new file mode 100644
        index 0000000..2eef361

        --- /dev/null
        +++ b/src/cmd/go/testdata/script/work_use_issue55952.txt
        @@ -0,0 +1,11 @@
        +! go list .
        +stderr '^go: cannot load module listed in go\.work file: open .+go\.mod:'

        +
        +-- go.work --
        +use ./y
        +-- x/go.mod --
        +module x
        +
        +go 1.19
        +-- x/m.go --
        +package m

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

        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: Ia45dd915e3fbd6e33340f352b3d6235c6c31190b
        Gerrit-Change-Number: 438147
        Gerrit-PatchSet: 6
        Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
        Gerrit-Reviewer: Alan Donovan <adon...@google.com>
        Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
        Gerrit-Reviewer: Gopher Robot <go...@golang.org>
        Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
        Gerrit-Reviewer: hopehook <hope...@golangcn.org>
        Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
        Gerrit-CC: Russ Cox <r...@golang.org>
        Gerrit-CC: Zeke Lu <lvz...@gmail.com>
        Gerrit-MessageType: merged
        Reply all
        Reply to author
        Forward
        0 new messages