Skip to content

x/tools/go/analysis: framework for analyzing module graph #44753

Open
@carnott-snap

Description

@carnott-snap

background

An analysis framework was built out for the go language, to make writing linters (and metalinters easier). go.mod files are another custom dsl, where you may want to enforce standards. Thus it seems reasonable to make an analysis package for modules.

One of the big potential benefits is an official "get me the main go.mod" function, since currently guessing or slurping go env -json are the best bad options. Furthermore, third party go.mod linters have already started popping up: gomodguard.

alternatives

The exact location is not terribly important, it could also be golang.org/x/tools/go/analysis/modanalysis or golang.org/x/mod/analysis, but golang.org/x/tools/go/analysis/modanalysis seems reasonable.

Instead of adding a whole new package and interface, it may be easier to add a ModPass struct based on the go.mod syntax, a new ModRun func(*ModRun) (interface{}, error) struct field, and the plumbing to read in the main go.mod. This seems like a choice for someone more familiar with the current package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    AnalysisIssues related to static analysis (vet, x/tools/go/analysis)FeatureRequestIssues asking for a new feature that does not need a proposal.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions