Original post

I’ve been trying – unsuccessfully – to find some good examples of Clean Architecture written in , but where there are multiple domains in the same project.

For various reasons, I’m writing my current project as a single monolith instead of as microservices. Nothing wrong with that, and it takes a lot of complexity out – which is good because I’m using it to learn Go properly.

I’m also trying to follow a good architecture pattern for it, to keep things well organised. And the Clean Architecture is what I’ve decided to go for.

There are lots of examples of this in Go out there, but they’re all for small projects, where there’s only one or two domains so they put everything together. As in, there’s an entities package containing all the entities from all the domains, a usecases package with all the use cases from all the domains, and so on

This works well enough for small projects, but doesn’t scale.

Instead I’m wanting to have each domain individually packaged, and use the visibility rules to keep the internals hidden from other domains.

Following the above and making one set of packages for each domain will lead to having lots of packages with the same name, which just seems painful.

Conversely, putting each domain in a package and not structuring it seems like it will work better, but I’m worried the package will quickly become a mess of files, and make it easy to break the dependency arrows.

Are there any decent examples of how to achieve something like this? Repos, articles, whatever. 🙂

Cheers