Skip to content
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: cmd/go: add shortcut "self" for the current module as in go.mod #28193

Closed
snobb opened this issue Oct 13, 2018 · 3 comments

Comments

Projects
None yet
3 participants
@snobb
Copy link

commented Oct 13, 2018

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.

@snobb 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 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

@gopherbot gopherbot added this to the Proposal milestone Oct 14, 2018

@gopherbot gopherbot added the Proposal label Oct 14, 2018

@rsc

This comment has been minimized.

Copy link
Contributor

commented Oct 17, 2018

Import paths are always fully qualified in Go. This is a property we very much want to keep.

@rsc rsc closed this Oct 17, 2018

@snobb

This comment has been minimized.

Copy link
Author

commented Dec 19, 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?

@snobb

This comment has been minimized.

Copy link
Author

commented Dec 19, 2018

Nevermind: I see you've answered this already: #26645 (comment)
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.