Menu

1 / 2

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

DEV Community·Bala Paranj·6 months ago
#ECcXczdU
#go#refactoring#architecture#every#zero
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.…

Continue reading — create a free account

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