Duplicate Imports
ID |
go.duplicate_imports |
Severity |
info |
Remediation Complexity |
medium |
Remediation Risk |
low |
Remediation Effort |
medium |
Resource |
Code Smell |
Language |
Go |
Tags |
code-style, imports |
Description
Reports the same import path imported more than once in a source file, whether inside one
grouped import (…) block or spread across several declarations. A repeated import adds
nothing and only clutters the import section.
Rationale
Duplicate imports are dead weight: they lengthen the import block, make it harder to see which packages are actually in use, and add noise to diffs and merges. They usually slip in through a careless merge or a forgotten line. Keeping a single occurrence of each path keeps the import section honest.
import (
"fmt"
"os"
"fmt" // FLAW — fmt already imported
)
import "os" // FLAW — os already imported above
import "strings" // OK — imported only once