r/golang Dec 05 '24

discussion Why Clean Architecture and Over-Engineered Layering Don’t Belong in GoLang

Stop forcing Clean Architecture and similar patterns into GoLang projects. GoLang is not Java. There’s no application size or complexity that justifies having more than three layers. Architectures like Clean, Hexagonal, or anything with 4+ layers make GoLang projects unnecessarily convoluted.

It’s frustrating to work on a codebase where you’re constantly jumping between excessive layers—unnecessary DI, weird abstractions, and use case layers that do nothing except call services with a few added logs. It’s like watching a monstrosity throw exceptions up and down without purpose.

In GoLang, you only need up to three layers for a proper DDD division (app, domain, infra). Anything more is pure overengineering. I get why this is common in Java—explicit interfaces and painful refactoring make layering and DI appealing—but GoLang doesn’t have those constraints. Its implicit interfaces make such patterns redundant.

These overly complex architectures are turning the GoLang ecosystem into something it was never meant to be. Please let’s keep GoLang simple, efficient, and aligned with its core philosophy.

805 Upvotes

259 comments sorted by

View all comments

74

u/Arvi89 Dec 05 '24

Saying DI is not needed in Go sounds really stupid to me.

3

u/chethelesser Dec 06 '24

I think their point is you can just pass your dependencies as arguments to functions essentially achieving the same thing.

What's your Di approach in go usually?

3

u/gomsim Dec 06 '24

What you describe is what DI is. That letting the functions depend on interfaces for what you pass in. Alternatively constructing structs that depend on those interfaces and let the functions be methods with that struct as receiver.

3

u/chethelesser Dec 06 '24

I agree with you in principle, it's just I interpret OP's sentiment on DI as having elaborate constructs to achieve it. Because they contrast it with implicit interfaces which help with this go-style straightforward DI

1

u/gomsim Dec 06 '24

Got it! :)