The go command used to infer the module path from .git/config for github origins specifically. However, that was removed in 1.13, based on discussion in #27951 <https://github.com/golang/go/issues/27951>. It wasn't a strong enough signal, and since it's important to get the module path right early on, it seemed better to require that the path be set explicitly when it can't be inferred from the location within $GOPATH/src.
On Wed, May 12, 2021 at 11:01 AM Jon Calhoun <joncalh...@gmail.com> wrote: > I suspect that the VCS path gives nearly the same level of confidence in > practice. My personal experience shows that it is pretty rare for the two > not to line up, and when it does the developer made a conscious decision to > do so and knows to work around it. > > I'm also not suggesting that we remove existing behavior. go mod init > <your module name> is still valid so we don't lose robustness there. > > > On Wednesday, May 12, 2021 at 10:42:29 AM UTC-4 Bryan C. Mills wrote: > >> go mod init should only infer a module path when it can be certain that >> path is correct. >> >> For packages already stored in GOPATH/src, it knows the correct path with >> high confidence: the path relative to GOPATH/src is the path by which the >> packages in the module are imported when in GOPATH mode, so it is safe to >> assume the same path in module mode. >> >> On the other hand, a module hosted at a particular VCS path can be served >> through an arbitrarily different path using go-import >> <https://golang.org/ref/mod#vcs-find> metadata >> <https://golang.org/ref/mod#vcs-find>, and it could also be a private >> fork intended for use only with a replace directive >> <https://golang.org/ref/mod#go-mod-file-replace> (or intended to >> temporarily host a change while an upstream PR is outstanding). So we >> cannot assume that the VCS path necessarily corresponds to the module path >> — it seems more robust to ask the user to supply the intended path >> explicitly. >> >> On Wednesday, May 12, 2021 at 9:25:48 AM UTC-4 jonca...@gmail.com wrote: >> >>> After more thought, the proposal should be altered to only support git >>> in the first pass. It would cover a majority of users, wouldn't affect the >>> experience in other VCS, and would simplify the initial implementation. >>> >>> Doing every VCS at once would require someone learning how every VCS >>> defines the default remote repository (if it even does), and building off >>> that. It would be better to do each individually and let someone familiar >>> with each VCS take charge of that specific PR using existing VCS >>> implementations as a pattern to follow. >>> On Wednesday, May 12, 2021 at 7:28:11 AM UTC-4 ohir wrote: >>> >>>> Dnia 2021-05-11, o godz. 11:14:24 >>>> Jon Calhoun <jonca...@gmail.com> napisał(a): >>>> >>>> > it saves me a handful of keystrokes at best - so I understand if it >>>> doesn't seem >>>> > worth the effort. >>>> >>>> Right. >>>> >>>> > It feels close enough to the current behavior to be a good addition >>>> >>>> Gopath is retiring soon. Anyway, Someone needs to do many more >>>> keystrokes >>>> to int repository anyway. >>>> >>>> > , but I admittedly haven't explored how easy/hard it would be to >>>> implement. >>>> >>>> Look at the list of currently supported VCSes to get a feel of the >>>> task. >>>> For the starter: infer module name from a Fossil's checkout file (it is >>>> a sqlite db). >>>> >>>> Hoe this helps >>>> >>>> > Best, >>>> > Jon >>>> >>>> -- >>>> Wojciech S. Czarnecki >>>> << ^oo^ >> OHIR-RIPE >>>> >>> -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/7beb2ab6-940c-451c-bee6-45ccf73ad8edn%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/7beb2ab6-940c-451c-bee6-45ccf73ad8edn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAGCADba09WLXZ%3D9oYK9OiZFNQ7%2BU_PUaJtNra0mK6KzK%2BDfOtw%40mail.gmail.com.