cmd/go: file system replace only works if target has go.mod #31052
Labels
FrozenDueToAge
GoCommand
cmd/go
modules
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I have some code that depends on
github.com/mattn/go-runewidth
, which has semver tags but no go.mod file.The
replace
directive in go.mod allows replacing a dependent module with local code by giving it a path. So I tried the following to use my local copy of the go-runewidth package (inside an existing GOPATH, by the way):What did you expect to see?
I expected
go build
to use that copy of the package, whether it has a go.mod file or not.What did you see instead?
Adding a go.mod file with just the "module" line in the go-runewidth directory makes the build work.
I thought that was surprising, and it reduces the value proposition of
replace
while many dependencies do not have go.mod files yet.The text was updated successfully, but these errors were encountered: