Menu

Post image 1
Post image 2
1 / 2
0

Zero-cost abstractions in Go: deleting your way to better code

DEV Community·Bala Paranj·18 days ago
#ECcXczdU
Reading 0:00
15s threshold

The most impactful refactoring in a Go CLI wasn't adding code — it was deleting pass-through layers, thin wrappers, and premature frameworks. Here's how to recognize abstractions that cost more than they save. Over 60 refactorings on a security CLI, the highest-ROI changes were deletions. Deletions of abstractions that existed "just in case" and cost every reader cognitive overhead with zero runtime benefit. Here are the abstractions we removed and why. 1. Pass-through packages A package that exists only to forward calls to another package: // internal/app/workflow/evaluate.go package workflow func Evaluate ( input EvalInput ) ( Result , error ) { return eval . Evaluate ( input ) // just forwards } Enter fullscreen mode Exit fullscreen mode Every command imported workflow instead of eval directly. The package had no logic, no transformation, no error handling. It was a phantom layer — it appeared in import paths, confused grep results, and added one more package to understand. The fix: Delete the package.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More