-
Notifications
You must be signed in to change notification settings - Fork 17.6k
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
cmd/doc: 'go doc $pkg' prefers GOPATH instead of active module #28992
Comments
I was under the impression that I presume that we should keep the GOPATH logic for when the command is called outside a module, and introduce module logic otherwise. I believe that only |
No, we should only use the In module mode outside of a module (as of CL 148517) we should produce documentation for the |
@myitcv rightfully pointed out https://go-review.googlesource.com/c/go/+/126799 - it does seem like support was added. |
Ah, looks like the bug is here: Line 165 in 96d4178
I'm setting |
Turns out not to be so trivial after all. CL 126799 added module-mode support for everything except packages, which apparently need more than just the source code for the package (i.e. need CC @matloob |
Change https://golang.org/cl/151617 mentions this issue: |
Previously, we were looking for the string go.mod specifically, but the module-mode-outside-a-module logic added in CL 148517 sets GOMOD to os.DevNull Updates #28992 Change-Id: I62a4baaa911a495350294d78bae96be3fe4866cb Reviewed-on: https://go-review.googlesource.com/c/151617 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
I tested with the following steps, using Go 1.12.4:
It seems that There is an issue of |
@dmitshur, is this still in progress? (If so, are you still planning to fix it for 1.13, or should we move it to the 1.14 milestone?) |
This is in progress, I am investigating it now. If the bug fix ends up being reasonable, it can still go into 1.13. If it turns out to be very complicated and risky, we can consider pushing it to 1.14. |
The problem was that a few |
Change https://golang.org/cl/183991 mentions this issue: |
go doc
calls out tocmd/doc
, andcmd/doc
implicitly usesGOPATH
to resolve the imports instead of looking in the active modules. That results in unexpected skew: it produces spurious failures when the package exists but is not inGOPATH
, and spurious documentation ifGOPATH
contains unpublished changes (as in the example in the details below).This is one instance of #24661, but the tool in question happens to be bundled with
cmd/go
and released with the Go toolchain: we should fix it sooner rather than later.CC @robpike @mvdan @ianthehat @rsc
The text was updated successfully, but these errors were encountered: