Skip to content

Commit abd7741

Browse files
committed
do not use base name of the directory as module name
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"
1 parent 5123622 commit abd7741

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/cmd/go/internal/modload/init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ func LoadModFile(ctx context.Context) *Requirements {
719719
data, f, err := ReadModFile(gomod, fixVersion(ctx, &fixed))
720720
if err != nil {
721721
if inWorkspaceMode() {
722-
base.Fatalf("go: cannot load module %s named in go.work file: %v", filepath.Base(modroot), err)
722+
base.Fatalf("go: cannot load module added to go.work file: %v", err)
723723
} else {
724724
base.Fatalf("go: %v", err)
725725
}

src/cmd/go/testdata/script/work_use_issue55952.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
! go list .
2-
stderr '^go: cannot load module y named in go\.work file: open .+go\.mod: no such file or directory$'
2+
stderr '^go: cannot load module added to go\.work file: open .+go\.mod: no such file or directory$'
33

44
-- go.work --
55
use ./y

0 commit comments

Comments
 (0)