Skip to content

x/tools/gopls/internal/analysis/modernize: use new reflect iterator APIs #75693

@aclements

Description

@aclements

#66631 adds iterator forms of several existing reflection APIs. We should add a modernizer to rewrite the non-iterator forms to the iterator forms when used in a simple loop.

Example rewrite:

var v Value
for i := range v.NumFields() {
	f := v.Field(i)
	// ... use f ...

	// Optional:
	sf := v.Type().Field(i)
	// ... use sf ...
}
var v Value
for sf, f := range v.Fields() {
	// ... use f and sf ...
}

Metadata

Metadata

Assignees

Labels

AnalysisIssues related to static analysis (vet, x/tools/go/analysis)FeatureRequestIssues asking for a new feature that does not need a proposal.ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions