deps/unused-check/go
Unused dependencies are detected
Implements deps/unused-check for go.
| Severity | info |
| Tiers | 1 |
| Stacks | go |
| Scope | each |
| Kind | outcome |
| Source | library v0.8.0 |
| Selected by | fleetlint-recommended@v0.8.0 |
Requirement
A recipe or CI step runs go mod tidy -diff (Go 1.23+), or go mod tidy followed by git diff --exit-code, which fails when go.mod requires a module nothing imports.
Why
Every declared dependency is attack surface and update churn; one nothing uses is pure cost.
Parameters
runners:[../Makefile ../justfile ../Justfile ../Taskfile.yml ../Taskfile.yaml ../../Makefile ../../justfile ../../Justfile ../../Taskfile.yml ../../Taskfile.yaml ../../../Makefile ../../../justfile ../../../Justfile ../../../Taskfile.yml ../../../Taskfile.yaml]skip:^\s*[@+-]*\s*(\{\{[^}]*\}\}\s*|\$[({][A-Za-z_]+[)}]\s*)?(#|//|echo\b|printf\b|(sudo\s+)?(go (install|get)|cargo b?install|pipx? install|pip3 install|python3? -m pip install|uv (tool |pip )?(install|add)|(npm|pnpm|yarn|bun) (i|install|add|global add)|gem install|bundle add|brew install|dotnet tool (install|update)|composer (global )?require|apt(-get)? install|curl|wget)\b[^;&]*$)
Fix
Run go mod tidy -diff in the audit target.
Agent instruction (from deps/unused-check): Add the stack’s unused-dependency checker to the audit target; remove the dependencies it reports in a separate change after confirming nothing loads them dynamically.
A finding that names no file points at the task runner’s file, or Makefile when there is none.
Sources
- https://fleetlint.org/baseline/#dependencies (convention)
- https://go.dev/ref/mod (spec, go mod tidy)
- https://fleetlint.org/stacks/#go
Generated by fleetlint docs from catalog v0.8.0.