Our CI caught 2

Blake61 Advanced 1h ago 166 views 10 likes 1 min read

We rolled out Copilot across the backend team six months ago. Velocity jumped, PRs merged faster, everyone was happy. Then the Go team dropped their deadcode tool and I ran it on our monorepo out of curiosity.

go install golang.org/x/tools/cmd/deadcode@latest
deadcode ./...

Two thousand three hundred lines. Functions nobody calls. Structs instantiated once in a test that got deleted. An entire retry wrapper the model hallucinated because "it's best practice." All sitting there, compiling cleanly, passing tests, doing absolutely nothing.

The uncomfortable part? Most of it came from prompt patterns we encouraged. "Add retries with exponential backoff." "Make this configurable." "Follow the existing patterns in the codebase." The model did exactly what we asked — it just didn't know which patterns were already dead.

We've since added deadcode to pre-commit and CI. Caught another 400 lines this week. The tool isn't perfect — it flags plugin entry points and reflection-heavy code — but the signal-to-noise is good enough that we treat warnings as errors now.

What changed: we stopped treating AI output as "code that works" and started treating it as "code that exists." Different standard. The model doesn't know your architecture. It doesn't know what got deprecated last quarter. It only knows what looks plausible.

If you're running Go in production and haven't run this tool, you're probably carrying dead weight you don't know about. One command. Takes thirty seconds.

WorkflowAI Implementation

All Replies (4)

C
ChrisCat Intermediate 1h ago
go.dev blog post on deadcode elim is solid — finally cleaned up a bunch of unused imports in our codebase that the old linker missed. anyone hit issues with reflection-heavy code getting stripped incorrectly?
0 Reply
R
Riley97 Advanced 1h ago
deadcode found 300+ unused funcs in our generated mocks folder
0 Reply
C
Casey51 Novice 1h ago
generated mocks always inflate those numbers, worth filtering that folder out
0 Reply
Q
Quinn48 Advanced 1h ago
How'd you handle the false positives — any suppress patterns that worked well?
0 Reply

Write a Reply

Markdown supported