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: "go get" should create a replcae line automatically if the get path and moudle path don't match #30705
Comments
What's the motivation for it to automatically create a replace line in go.mod file? At first glance, that kind of behavior would be unexpected and surprising to me, given how |
I think the motivation is straightforward. The intention of why I run "go get" is just to add a dependency to the current module-aware user package. For the library package is hosted on github.com, certainly I can't run "go get go101.org/tinyrouter@v1.0.1", for the library package isn't hosted on go101.org. The |
And I found that, even if I put the replace line manually to the
I really don't know why |
|
What is the intended import path for Go packages in tinyrouter? If you want the import path to be If you want the import path to be |
The intention is to avoid my library users being locked down to Here, the |
If |
Module paths are canonical: if a module sets the path
Please see When should I use the replace directive? on the module wiki for more information on See Remove import paths for more information on custom imports. These are popularly (but not officially) called "vanity imports", and there are some articles on setting that up. You definitely need to serve |
It's not okay if you want users to be able to install the dependency from the internet. To do that, they would use That's why the import path should be a URL that you have control over (such as |
I did run the Do you mean I should not place a
I just think it is totally unnecessary to let |
sorry, I use a wrong word in the last comment, "efficient" should be "sufficient". |
I just hope
is a shortcut for
I think this a reasonable hope. |
@go101 When a user imports If it didn't work this way, anyone would be able to write |
Then why doesn't |
Ok, I think I got it. The difference is, one is "initiative", and the other is "passively". |
What version of Go are you using (
go version
)?go version go1.12 linux/amd64
Does this issue reproduce with the latest release?
yes
What did you do?
The module path set in
go.mod
isgo101.org/tinyrouter
, notgithub.com/go101/tinyrouter
.What did you expect to see?
no errors, and automatically create a replace line in go.mod file of the app project after parsing the go-got go.mod file:
What did you see instead?
The text was updated successfully, but these errors were encountered: