You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Provide a variable/macro for go.mod module to use in import statement.
Currently one has to type the full module name in import for internal packages. Eg. if go.mod module is github.com/user/repo, the import of an internal package would have to be: import "github.com/user/repo/internal/package". It's a lot of typing and pretty redundant as well. So it would be nice to have a shortcut like self(or root), so that the import looks like: import "self/internal/package".
Also it would make it much easier to rename the module, since in this case it won't be required to go and edit every single source file.
The text was updated successfully, but these errors were encountered:
snobb
changed the title
cmd/go - add shortcut "self" for the current module as in go.mod
cmd/go - add shortcut "self" for the current module as in go.mod (feature request)
Oct 13, 2018
agnivade
changed the title
cmd/go - add shortcut "self" for the current module as in go.mod (feature request)
proposal: cmd/go: add shortcut "self" for the current module as in go.mod
Oct 14, 2018
I appreciate that the proposal is rejected and the language architects have different opinion on this.
Just out of curiosity - can you please provide a reason why this is a preferred way and why a shortcut is not an option? Is there a spec document that I can read that provides some background for this decision?
Provide a variable/macro for go.mod
module
to use inimport
statement.Currently one has to type the full module name in import for internal packages. Eg. if
go.mod
module isgb.xjqchip.workers.dev/user/repo
, the import of an internal package would have to be:import "github.com/user/repo/internal/package"
. It's a lot of typing and pretty redundant as well. So it would be nice to have a shortcut likeself
(orroot
), so that the import looks like:import "self/internal/package"
.Also it would make it much easier to rename the module, since in this case it won't be required to go and edit every single source file.
The text was updated successfully, but these errors were encountered: