Skip to content

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

@dmitshur

Description

@dmitshur

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureRequestIssues asking for a new feature that does not need a proposal.FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.ToolsThis label describes issues relating to any tools in the x/tools repository.modules

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions