Skip to content

Commit 9eee0ed

Browse files
author
Jay Conrod
committed
cmd/go: fix go.mod file name printed in error messages for replacements
This fixes a logic error introduced in CL 337850. Fixes #47444 Change-Id: I6a49c8fc71fdde4ecb7f2e3329ad1f2cd286b7eb Reviewed-on: https://go-review.googlesource.com/c/go/+/338189 Run-TryBot: Jay Conrod <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Michael Matloob <[email protected]> Trust: Jay Conrod <[email protected]>
1 parent b39e0f4 commit 9eee0ed

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/cmd/go/internal/modload/modfile.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -652,8 +652,8 @@ func rawGoModData(m module.Version) (name string, data []byte, err error) {
652652
if !filepath.IsAbs(dir) {
653653
dir = filepath.Join(ModRoot(), dir)
654654
}
655-
gomod := filepath.Join(dir, "go.mod")
656-
if gomodActual, ok := fsys.OverlayPath(gomod); ok {
655+
name = filepath.Join(dir, "go.mod")
656+
if gomodActual, ok := fsys.OverlayPath(name); ok {
657657
// Don't lock go.mod if it's part of the overlay.
658658
// On Plan 9, locking requires chmod, and we don't want to modify any file
659659
// in the overlay. See #44700.
@@ -662,16 +662,17 @@ func rawGoModData(m module.Version) (name string, data []byte, err error) {
662662
data, err = lockedfile.Read(gomodActual)
663663
}
664664
if err != nil {
665-
return gomod, nil, module.VersionError(m, fmt.Errorf("reading %s: %v", base.ShortPath(gomod), err))
665+
return "", nil, module.VersionError(m, fmt.Errorf("reading %s: %v", base.ShortPath(name), err))
666666
}
667667
} else {
668668
if !semver.IsValid(m.Version) {
669669
// Disallow the broader queries supported by fetch.Lookup.
670670
base.Fatalf("go: internal error: %s@%s: unexpected invalid semantic version", m.Path, m.Version)
671671
}
672+
name = "go.mod"
672673
data, err = modfetch.GoMod(m.Path, m.Version)
673674
}
674-
return "go.mod", data, err
675+
return name, data, err
675676
}
676677

677678
// queryLatestVersionIgnoringRetractions looks up the latest version of the

0 commit comments

Comments
 (0)