-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: Why not separate the module name and the download URL? #30242
Comments
Go do not separate the module name and the download URL that is sick |
@AllenYN reminder to keep it civil in the issue tracker. Only comment if you have technical arguments about the issue. "this is sick" doesn't really add anything meaningful to the thread. @googollee there's good reason to include the module path in I presume losing that property would have a high cost, besides being a backwards incompatible change. I'm not convinced that the advantages are worth it.
This doesn't seem like a strong argument. Verbosity is fine if it adds useful information.
Like I described above, this information is required on purpose. There's no misleading.
You can just use replace directives; see https://github.com/golang/go/wiki/Modules#when-should-i-use-the-replace-directive. |
@mvdan, I know there is replace directives. From my recent experience, it's kind of misleading thing. I go to the original repo instead of forked one many times when I just check the code and go directly to the importing address. Further more, I recognize the forked repo is the branch of the original one, but not a different repo. They should share the same identifier in some way. |
And they do. Both |
Module-mode has a different goal for the
I'm not sure what you mean by this.
If both forks are maintained, then it is important for importers to be explicit about which fork they actually tested against. Today, they do that using a |
Coupling the module path to the URL has another purpose, too: it eliminates the possibility of collisions without the need to maintain our own central module-path registrar. The Domain Name System already moderates a global namespace, and we need to use DNS to fetch modules anyway, so we may as well piggyback uniqueness of the Go import-path namespace on the existing system of unique URL paths. This aspect of the modules design is not going to change. |
so if I want to fix some bugs from original author's repo, I need to both modify |
@sound2gd I encountered this use case and worked around it via the method outlined here: #29299 (comment) |
@sound2gd, if you have a repo that is only usable as a replacement for a specific module, then the |
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 a package with go module in github.com/googollee/mypkg. The go.mod file is
Then I
go get
this package and want to use it in another project with go module.What did you expect to see?
go get
runs successfully and I can import with namemypkg
.Separating the module name and the download URL will have benefits below:
Shorten the import clause.
Won't mislead the address of importing packages.
If someone forked projects, no need to change import paths in existing codes.
E.g., I use mypkg in another project Main and import like below:
Saying, Bob wants to add some patches and forks both project mypkg and project Main. He could just change the URL in project Main's go.mod to use project mypkg which he forked and keeps all other codes same as upstream. It's not only make the import clause clearly but also reduce the work when catching up the upstream code.
What did you see instead?
When I
go get
in another project with go.mod, I got:The text was updated successfully, but these errors were encountered: