The controversy of using Clean Architecture in Golang

The controversy of using Clean Architecture in Golang

Clean Architecture, by Robert C. Martin (Uncle Bob), is a design pattern for software. It focuses on separating concerns, testing, and maintaining code. But, using Clean Architecture in Golang applications has stirred debate. This is because Golang's philosophy differs from some aspects of Clean Architecture. The main controversies include:

  1. Interface pollution: Clean Architecture uses many interfaces to separate layers. Golang prefers small, single-responsibility interfaces. Applying Clean Architecture to Golang may create larger interfaces, breaking Golang's style.
  2. Package structure: Clean Architecture organizes code into layers. Golang favors simple package structures based on functionality. This creates a clash between Clean Architecture and Golang best practices.
  3. Dependency injection: Clean Architecture relies on dependency injection. Golang keeps things simple and lacks built-in dependency injection. Using dependency injection in Golang adds complexity and may need extra libraries.
  4. Testability: Clean Architecture aims to improve testability. Golang already supports testing well, with built-in tools and simplicity. Applying Clean Architecture to Golang might not improve testability but add complexity.


These controversies don't mean Clean Architecture won't work in Golang applications. Developers have used Clean Architecture successfully in Golang projects. But, it's crucial to adapt Clean Architecture principles to fit Golang's style and practices, instead of strictly following it.