Inspectopedia
 
2024.3

Unused dependency

Warning
Sanity
Last modified: 03 December 2024

Reports unused dependencies.

For each dependency in the current go.mod file, this inspection searches for any import statement starting with the dependency name in all GO files. If no such imports found then the dependency is considered unused. This inspection is an equivalent of the go mod why command.

The inspection processes require and replace directives. The require directives with // indirect comments are also processed.

The inspection might not accurately determine that a replaced or indirectly-required dependency is unused in the following cases:

  • Vendoring mode is enabled

  • Some dependencies are not downloaded