-
Notifications
You must be signed in to change notification settings - Fork 17.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/go: report original module path in error parsing replaced go.mod
MVS reports an error when a go.mod file declares a module path that doesn't match the path it was required with. If the module is a replacement, its declared path may be the original path (preferred) or the replacement path. This CL makes the reported error a little more clear: the "required as" path should be the original required path, not the replacement path. Fixes #38220 Change-Id: I08b50a100679a447c8803cca1d1b32bc115ec1b1 Reviewed-on: https://go-review.googlesource.com/c/go/+/227097 Run-TryBot: Jay Conrod <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]>
- Loading branch information
Jay Conrod
committed
Apr 3, 2020
1 parent
d786395
commit c4f875e
Showing
3 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
This module is a replacement for rsc.io/quote, but its go.mod file declares | ||
a module path different from its location and the original module. | ||
|
||
-- .mod -- | ||
module rsc.io/Quote | ||
|
||
go 1.14 | ||
-- .info -- | ||
{"Version":"v1.5.2"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# If a replacement module declares a module path different from both | ||
# the original module and its location, report an error with all three paths. | ||
# In particular, the "required as" path should be the original. | ||
# Verifies golang.org/issue/38220. | ||
! go list . | ||
cmp stderr want | ||
|
||
-- go.mod -- | ||
module m | ||
|
||
require rsc.io/quote v1.5.2 | ||
|
||
replace rsc.io/quote v1.5.2 => example.com/quote v1.5.2 | ||
|
||
-- use.go -- | ||
package use | ||
|
||
import _ "rsc.io/quote" | ||
|
||
-- want -- | ||
go: example.com/[email protected]: parsing go.mod: | ||
module declares its path as: rsc.io/Quote | ||
but was required as: rsc.io/quote |