-
Notifications
You must be signed in to change notification settings - Fork 17.6k
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
proposal: x/vgo: allow aliases in go.mod #25518
Comments
One goal of vgo is to not make the source go files dependent on the module file. If the vgo file is removed, the worset result is a fresh build gets the latest in major version series. This proposal appears to break that principal. |
@kardianos |
The build tools do not issue any warnings. It should stay that way. Also, import paths are not repository paths. Vgo doesn't change that. Maybe you can use vgo's existing replace directive to achieve what you want? |
I also do not like the way that the paths are hardcoded. For example in Angular 2+, I can move any module to a new location or to a new application without any changes. And in Golang I have to do a search and replace all the files to replace all the paths. |
Doing textual search-and-replace is not particularly burdensome for programmers. It's something we already do in all sorts of contexts every day. |
@frou |
Coincidentally, @rsc brought up exactly this point in blog post part 9:
|
See also #3515. |
Per text @bcmills quoted, vgo is working as intended. While it may be true that you can solve everything in computer science with another level of indirection, new levels of indirection also add new complexity in understanding the system. We're explicitly avoiding an indirection here, by design. |
As of today, it is required to hardcode the full import path of dependencies in each go file, this proposal is to define an alias for the dependencies directly in the go.mod file and to use it throughout the code.
For example, this is a typical go.mod file:
Currently, the dependencies in a go file are imported this way:
With this proposal, the aliases could be specified directly in the go.mod file. For example, introducing the aliases in the previous go.mod file:
the go code becomes:
This permits to decouple the source code from the physical location of a dependency and to, for example, easily switch to a fork with a single change in the go.mod file.
The text was updated successfully, but these errors were encountered: