-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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/go: module mode removes concept of global docs #33710
Comments
That seems like the correct behavior most of the time. In particular:
CC @jayconrod |
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. Maybe |
This is gated on figuring out the design for “global” operations throughout the |
Considering the changes that are planned for Go 1.16, is there already some obvious way forward for |
We've been adding version support to commands like But that would be very slow for |
#43646 is related, in the sense of wanting to scope a |
I'm thinking aloud here, so this might be a terrible idea, but... We can live with pkg.go.dev potentially lagging behind the "true" latest branch by up to thirty minutes, given its caching and version discovery logic. Could we not make I definitely think that behavior would be wrong for commands which are designed around fetching the latest version, like |
The ergonomics of
go doc
have regressed in go1.13beta1.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
grep
orhead
to focus on relevant bits when I want to answer a question in chat/email.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?
CC @rsc (closing the loop from GopherCon), @bcmills (modules), and @dmitshur (go doc)
(Maybe I need to write/use a shell alias that runs
go doc
in the current directory, and on failure tries a second time in a different directory. I wonder if there are other cases where a fallback go.mod file would be helpful—here I'd use it for docs, but it could also set a default version in other cases where Go tools have to guess or decide to use "today's latest".)What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
This behavior is new since Go 1.12. It exists in go1.13beta1 and current tip, where module mode is enabled by default.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
I expected looking up docs from the command line for packages I've downloaded to my laptop to be really convenient. (I have many packages with docs of interest stored in my GOPATH.) I expected my ability to read those docs to not be strongly affected by my shell's current working directory. I expected that looking up docs for a package using its fully-qualified name would not affect the dependency manifest file in my shell's current working directory.
Put another way, I expected
go doc
to be a way of reading docs that's more convenient than godoc.org (particularly when I need to paste the result into a chat window, maybe after piping togrep
to point out a part of interest).What did you see instead?
When my shell's working directory is in GOPATH outside of a module (no go.mod file nearby), I can use
go doc
to look up documentation for any package in my GOPATH.When my shell's working directory is in GOPATH but inside a module,
go doc
only works for packages in modules that are referenced by the current module.The working directory is "in" a module now, and go1.13beta1 and tip can't load docs for the errgroup package. But go1.12.9 can load the docs just fine (below).
The text was updated successfully, but these errors were encountered: