Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
x/tools/gopls: respect GOPRIVATE setting when linking to pkg.go.dev (hover, documentLink) #36998
Currently, our hover text by default links point to public documentation sites (e.g. pkg.go.dev). This doesn't make sense for private repos, so hide the hovertext link when the import path matches GOPRIVATE. Implementing this was a little messy. To be optimal I had to thread the value of goprivate through cache.view, and to be correct I had to duplicate some code from cmd/go internal. Regtest will follow after https://golang.org/cl/232983 is submitted. Updates golang/go#36998 Change-Id: I1e556471bf919fea30132d9642426a08fdb7f434 Reviewed-on: https://go-review.googlesource.com/c/tools/+/233524 Run-TryBot: Robert Findley <firstname.lastname@example.org> TryBot-Result: Gobot Gobot <email@example.com> Reviewed-by: Rebecca Stambler <firstname.lastname@example.org>
Add a regtest to verify that GOPRIVATE identifiers are not given a link to pkg.go.dev. For efficiency, as well as to exercise dynamic configuration, do all this in a single regtest. Updates golang/go#36998 Change-Id: I9102a11312db5c334fdbd30cce9ca2d2e19e9ac2 Reviewed-on: https://go-review.googlesource.com/c/tools/+/237938 Run-TryBot: Robert Findley <email@example.com> TryBot-Result: Gobot Gobot <firstname.lastname@example.org> Reviewed-by: Rebecca Stambler <email@example.com>
@sandipb: yes, GOPRIVATE relates to proxy behavior when using modules. This bug is about hiding links to package documentation when paths match GOPRIVATE. If paths are private, it's likely that those links will be broken anyway.
But as you say, that only applies to module mode. Are you saying that if GO111MODULE=off, we shouldn't link to package documentation? Or are you saying if GO111MODULE=off we shouldn't check GOPRIVATE? There may be a bug, I'm not sure I understand your question.
Hi @sandipb -- both godoc.org and pkg.go.dev host package documentation. They are not proxies. Unlike godoc.org, pkg.go.dev is "module-aware", so you can see package documentation for older module versions.
In GOPATH mode, it still seems reasonable to link to package documentation for the package import path. In any case, if I recall correctly we link to the latest version of documentation, so whether using modules or not the linked package documentation might be for a newer version than what you are importing.
Agree with everything @findleyr said here, but wanted to add a quick point of clarification on the last statement:
We do link to the correct version of the docs (code here), so if you are using modules, you will get the correct versions.