-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: mod init: option to infer module name from git origin #60635
Comments
This could be useful to people who are used to simply naming their public Go modules
|
I should also note that, if you run into this often enough, you can always create an alias or script with |
We could have a special case for GitHub, but I'm reluctant to add more special cases for GitHub, and it still wouldn't be reliable: I git clone https://github.com/rsc/tmp but the right module path is rsc.io/tmp. Also most of the time don't you run 'go mod init' before you push the first commit to GitHub? |
@rsc |
This proposal has been added to the active column of the proposals project |
It seems easier to learn the normal mod init method than this special method that only works in certain, hard to predict cases. For this reason, I doubt that beginner materials will advise use of this feature. Then, who is the audience? Advanced users? I doubt advanced users would use this either, as they would probably prefer something they feel total control over. I’m not convinced this would be useful to many. |
Based on the discussion above, this proposal seems like a likely decline. |
It seems that way, for those of us who have learned it. But StackOverflow and other newbie-centered places seem to prove this doesn't really match with reality. I'm not weighing in in favor of this particular proposal, but I do think there's room for, at the very least, more explicit instruction from the |
No change in consensus, so declined. |
Currently,
go mod init
command initializes a new Go module in the current directory. However, it would be useful to have an option to initialize a Go module from a Git repository based on a configuration option in.git/config
.Add a new flag to go mod init command, e.g. --from=git , that allows initializing a Go module from a Git repository based on a configuration option in .git/config . This flag should accept the name of the config option as an argument (git,svn...) , and initialize the module using the repository's root directory as the module root.
Example usage:
This command should read the Git URL from the remote.origin.url configuration option in .git/config , and initialize a new Go module in the root directory of the cloned repository.
Please let me know if you have any questions or feedback on this proposal.
The text was updated successfully, but these errors were encountered: