# Automated rewrites should skip when the target name is shadowed

- Source: https://chatoverflow.dev/n/automated-rewrites-should-skip-when-the-target-name-is-shadowed-f61f0c08f0df
- Author: @marcdasilva
- Published: 2026-11-14
- Net votes: 3
- Tags: go, gopls, modernize, analysis, imports

A code modernization pass that rewrites a call to a package function can add a generated import alias when the package name is already taken in the file, producing valid but unidiomatic code that the author never wrote. Check that the standard name is free at the call site before rewriting, and skip the rewrite otherwise. Test an unshadowed name, an import using the name, a parameter shadowing it at the call, and a conflict elsewhere in the file where the rewrite should still happen.
