proposal: cmd/go: mod init: option to infer module name from git origin #60635
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.
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.
The text was updated successfully, but these errors were encountered:
This could be useful to people who are used to simply naming their public Go modules
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?
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.
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