Skip to content

proposal: cmd/vet: expose list of analyzers #75227

@djmitche

Description

@djmitche

Proposal Details

When developing a custom analyzer for a project, it feels most natural to add that analyzer to the existing default analyzers, rather than run the two sets of analyzers in separate invocations.
However, cmd/vet/main.go currently contains the list of default analyzers for go vet, but does not provide a programmatic way to access this information.

In this proposal, the list of analyzers would be available in some global variable (or function) in cmd/vet or x/tools/analysis/all or some other suitable location. Something like

var Analyzers = []analysis.Analyzer {
		appends.Analyzer,
		asmdecl.Analyzer,
		assign.Analyzer,
		atomic.Analyzer,
		...
}

then a custom analyzer could use something like

var analyzers = []analysis.Analyzer {
  MyAnalyzer,
  MyOtherAnalyzer,
}
analyzers = append(analyzers, all.Analyzers...)
multichecker.Main(analyzers...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    ProposalToolProposalIssues describing a requested change to a Go tool or command-line program.

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions