-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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 module-mode behavior of multi-element GOPATHs #29005
Comments
Having a multi-element GOPATH in the first place puts you firmly in the power-user category. I'm not sure that we need to warn about this because I'm skeptical that many users are in that situation to begin with... |
Agreed; I wonder if anyone else would even run into this issue. But still, it had me confused for a good twenty minutes, because I wasn't realising that I had two separate binaries for the same main package. Perhaps a better generic warning would be on the use of a multi-element |
I think that at least the "GOPATH and Modules" section in |
I also use a multi-element GOPATH, set to However I find it strange to have a GOPATH entry inside the other GOPATH entry. It should probably be disallowed. What is the reason for this choice? |
The choice was arbitrary, and it doesn't really matter anymore :) I dropped that configuration over a year ago when I fully switched all my projects to modules. |
I still have the multi-element GOPATH. Originally I used it to keep separate external packages and my packages, but now I'm still using it since it is nice to have the module cache in |
@bcmills, thanks. But what will happen to
I'm starting to call modules with this property local modules and I'm writing some tools to make it easy (as with gopath mode) to work with them. |
We're still figuring out the future of (Just be aware that modules, unlike GOPATH directories, can interleave: package example.com/foo/bar may be provided by module example.com, even if package example.com/foo is in its own distinct module in the middle.) |
At this point, I wonder whether we should instead update I'm not sure this is a problem in practice though. |
In my case,
mvdan.cc/sh/cmd/gosh
is a main package inside the second GOPATH directory. It's also a module, so it can be built in either mode.I understand why the GOPATH build puts the binary where it does - that's the old and documented logic.
And I too sort of understand why the module build goes into the first
GOPATH
entry - it's not building the package within any oneGOPATH
, so it just picks the first.However, this can be very confusing. In my case, I ended up with two binaries, and because of
PATH
I was always running the older. The only mention is brief, undergo help modules
:I realise now that my fix should be to either set up a global
GOBIN
, or to stop using a multi-elementGOPATH
. I still think the documentation could be clearer, though. I think we should discourage the use of a multi-element GOPATH with no GOBIN in the modules world, because of the tricky scenario above./cc @bcmills @myitcv @rogpeppe
The text was updated successfully, but these errors were encountered: