Skip to content
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

x/tools/godoc/analysis, x/tools/cmd/godoc: support type, pointer analysis in module mode #34473

Closed
dmitshur opened this issue Sep 23, 2019 · 3 comments
Labels
FeatureRequest FrozenDueToAge modules NeedsFix The path to resolution is known, but the work has not been done. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@dmitshur
Copy link
Contributor

dmitshur commented Sep 23, 2019

This is the tracking issue specifically for the golang.org/x/tools/cmd/godoc command to support type and pointer analysis (the -analysis flag) in module mode. This specific feature is factored out of issue #33655, which tracks basic documentation viewing functionality in module mode. The parent umbrella issue for all “godoc”-like projects is #26827.

godoc has a static analysis mode that was added in Go 1.3. It is documented at https://golang.org/lib/godoc/analysis/help.html.

I expect that this static analysis mode may become quite useful in module mode. In GOPATH mode, a common problem was that it was too slow and often impractical when one had a large GOPATH workspace, because it tried to analyze packages from all GOPATH workspaces. In module mode, its scope will be limited to the active project, meaning it'll be more practical to have it turned on more often.

Plan

In order to support module mode, the golang.org/x/tools/godoc/analysis package will need to be updated to use golang.org/x/tools/go/packages to load packages, rather than the older golang.org/x/tools/go/loader. godoc has test coverage for this feature in GOPATH mode, they'll need to be expanded to cover module mode too. Finally, there are some nuances related to differences in how packages are listed between GOPATH and module modes (e.g., in GOPATH mode, all includes all standard library packages, but in module mode it has a different behavior) that will need to be reconciled.

I've prototyped a fix for this as part of work on issue #33655. It needs to be cleaned up, but it is functional and promising. I decided it's better to factor it out of that issue, since this functionality is more advanced and can be done afterwards.

@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. modules Tools This label describes issues relating to any tools in the x/tools repository. labels Sep 23, 2019
@dmitshur dmitshur added this to the Unreleased milestone Sep 23, 2019
@dmitshur dmitshur self-assigned this Sep 23, 2019
@dmitshur
Copy link
Contributor Author

The work to add this feature isn't complete, and by now more active development on a tool to display documentation locally is in x/pkgsite (see tracking issue #40371), so this is obsolete. Closing.

@dmitshur dmitshur removed their assignment Oct 28, 2021
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/358954 mentions this issue: godoc/analysis: remove deprecated analysis package

@golang golang locked and limited conversation to collaborators Oct 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FeatureRequest FrozenDueToAge modules NeedsFix The path to resolution is known, but the work has not been done. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants
@dmitshur @gopherbot and others