New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/go: document that filesystem-based replace directives require that the right hand side have a go.mod #30847
Comments
This is likely related to #24110 @rsc states that this is "working as intended", but it doesn't seem obvious to me why the stated rationale applies - after all, go modules interop with non-go module adopting libraries fine outside of replace directives. In fact without the replace directive, if I want to use the public, non-forked version of said dependency, go modules seems to work with it fine... |
A related comment from Bryan:
|
FWIW, I think having a filesystem-based replace without a go.mod on the right-hand side is actually useful. I was expecting to use that for the following case: I have a large, curated existing GOPATH, made up of operating system packages for various Go libraries and to be used for builds of other OS packages (that's NetBSD pkgsrc, if you are wondering). Now I would like to replace a given module with its equivalent in the existing GOPATH. Because we are early in the development of modules, most of these have no go.mod of their own. Running Or am I thinking about this the wrong way? |
So,.... I've been bitten by #26366 for CGO-using module X, which is really annoying. I had hoped I could then just define a project local GOPATH= and have my main package in /src/main-package and have /src/X ... but no. GOPATH also stops working when GO111MODULE=on. All I wanted here was for go build -mod=vendor to find module X in it's complete form. Can it really be true that we have to introduce yet-another-tool to make this work. I had hoped to just use git and go. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
I believe 1.12 is the latest release
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
At work we internally have a fork of a particular module - call it
foo
. We have a fork offoo
internally for some minor changes. I had the fork checked out at my desired branch at./grant_modules_hack/vendor/foo
. (I was attempting to work around a private repo problem at the time).I added this replace directive:
What did you expect to see?
I expected this to work, with, say,
go build
.What did you see instead?
@thepudds confirmed to me that filesystem-based
replace
directives do require that the right hand side have ago.mod
.This should definitely be documented somewhere: I don't see this caveat listed anywhere here https://github.com/golang/go/wiki/Modules#when-should-i-use-the-replace-directive
The text was updated successfully, but these errors were encountered: