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
Closed

Comments

@snobb
Copy link

snobb 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
@rsc
Copy link
Contributor

rsc commented Oct 17, 2018

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

@snobb
Copy link
Author

snobb 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
Copy link
Author

snobb commented Dec 19, 2018

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

@golang golang locked and limited conversation to collaborators Dec 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants