Go Architecture Test

This is an example of a simple yet scalable Go directory structure.

/cmd

Entrypoints for the application. Each folder and main.go file within will be an executable binary, e.g. server, migrate, seeder.

/internal

Infrastructure packages containing implementation of external protocols like database connections, REST, gRPC, etc.

/pkg

Business use cases grouped by domains. Each file is a single use case expressed using ubiquitous domain language.

/

The root folder contains domain entities and interfaces for the given domain. Each entity can be unit-tested in isolation. Interfaces allows use cases not to rely on specific implementations.

GitHub

View Github