Sobes.tech
Senior

What architecture do you use in Go applications?

sobes.tech AI

Answer from AI

In Go applications, I often apply architecture based on Clean Architecture or hexagonal architecture to separate business logic from infrastructure and external dependencies. This makes it easy to test and maintain the code.

Main layers:

  • Entities — business logic and models.
  • Use Cases — usage scenarios implementing business rules.
  • Interface Adapters — adapters for interacting with the external world (HTTP, databases).
  • Frameworks & Drivers — specific implementations, such as web servers, database drivers.

In Go, this is often expressed as packages with clear interfaces, injected via dependency injection. I also actively use contexts (context.Context) to manage request lifetimes and cancel operations.

Example structure:

cmd/         # entry point
internal/    # business logic
  ├── entities/
  ├── usecases/
  ├── repository/
  └── delivery/  # HTTP handlers
pkg/         # common libraries
What architecture do you use in Go applications… - sobes.tech