golang / golang/go

x/tools/goimports: enable deleting without adding missing imports

Open
#76,745 8 comments 2 reactions 0 assignees View on GitHub
FeatureRequest NeedsInvestigation Refactoring Tools
Dominant language
Go
Stars
139k
Forks
19.4k
PR merge metrics
PR metrics pending

Description

Adding missing imports can take substantial time (~ 30-60 seconds in a large codebase) due to the need to load packages. This makes goimports problematic for "action on save" workflows, as saves would either block the editor or (if async) risk undoing user's work (when goimports eventually finishes and writes back the file).

I'd like to propose another flag, `-delete-only`, that'll produce only DeleteImport fixes, since I would assume that DeleteImport fixes can be produced quickly without loading packages either.

Contributor guide

Open the contributing guide

Research direction

Start by locating the goimports flag handling and the code that produces DeleteImport and missing-import fixes. Trace how package loading is triggered, then verify that -delete-only emits only DeleteImport fixes without waiting for missing-import analysis.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli, tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.