Skip to content

x/tools/go/analysis/internal/checker: -fix should remove unneeded imports #72035

Open
@adonovan

Description

@adonovan

The -fix flag of each {single,multi}checker tool applies as many fixes as possible without textual conflicts. However, semantic conflicts are still possible. The most common kind of semantic conflict is to leave unused imports in the file. Consider: if a file contains two fixes, each of which removes one use of an import, then each fix is safe to apply in isolation, but when applied together the import becomes unused.

This is sufficiently common that it is worth making the fixer's final step to check for unused imports and remove them, ideally without having to re-typecheck the file.

Metadata

Metadata

Assignees

Labels

FixPendingIssues that have a fix which has not yet been reviewed or submitted.ToolProposalIssues describing a requested change to a Go tool or command-line program.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