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
cmd/go: module mode removes concept of global docs #33710
The ergonomics of
Background on why and how this affects me: When I download code, I usually arrange it in my GOPATH (to organize it—even if it's not Go code). I usually have a shell (or ten) open, and the working directory is often one of the projects (under GOPATH) that I've worked on recently. Sometimes I want to look up docs for popular packages without opening a browser, especially so I can pipe the output through
As the projects in my GOPATH convert to being modules, they stop working for this kind of "go doc" usage. When my shell's working directory is in a module, "go doc" can only find packages that are in modules referenced by the current module. If I use a package's fully-qualified name to look up its docs, I end up with unintended changes to the nearby go.mod file.
This seems like an unfortunate implication of a bunch of other rules that make sense in isolation. But is this the right behavior for the tool?
(Maybe I need to write/use a shell alias that runs
What version of Go are you using (
That seems like the correct behavior most of the time. In particular:
That's the general theme of #32027. Use cases I'm aware of include:
For (1), in the case that the main module requires the package whose docs I'm trying to read, then I agree it should control which version of those docs get displayed.
For (2), I see
Using the module cache for (3) seems ok.