The Wire · Showcase
GOIMPORTS JUST GOT 3X FASTER
By RepoJournal · Filed · About Go
golang/tools cut goimports execution time from seconds to subseconds by leveraging the module cache index that gopls already builds.
The golang/tools team shipped an optimization that fundamentally changes how goimports scans dependencies [1]. Instead of brute-forcing the entire module cache on every invocation, the new code checks for an index first, the same one gopls creates during normal editing sessions. If that index exists, goimports uses it. If not, it falls back to the original behavior. The impact is measurable: on a standard laptop, execution drops to 0.66 seconds [1]. This is the kind of invisible performance win that compounds across a thousand editor saves in a workday. The implementation is clean - no test refactoring required because the existing test suite doesn't generate indexes, so nothing breaks.
One email a day. Unsubscribe in one click.
Keep up with Go in about 3 minutes a day: what actually shipped — the commits, pull requests, releases, and security advisories that matter.
One email a day. Unsubscribe in one click. Read a past issue →
Action items
- → Update golang/tools to get the goimports speedup in your next gopls sync golang/tools [plan]
References
- [1] internal/imports: use module cache index if it exists golang/tools