DEV Community

Steve Hiehn
Steve Hiehn

Posted on

How should go APIs be structured?

I'm working on a code base that is about yr old. We basically follow this pattern. Its working for us but I wish I had more examples of 'the GO way' to structure an API. Is there even a go way? Really we're just doing it the way a Java/C# API would.

/CORE/ #domian struts etc
/HANDLERS/ #just http interaction
/SERVICES/ #basically all the business logic
/DAL/ #data access (mostly postgres)

Discussion (2)

Collapse
gcdcoder profile image
Gustavo Castillo

I've been looking for information about this topic and I came across this repo github.com/golang-standards/projec..., and taking a look to other important projects such as Kubernetes, Docker, Stripe CLI etc it seems they follow this structure, it couldn't be the "official way" but it's widely use. But I'm opened to ideas about it though 🤓.

Collapse
cloakedstudios profile image
Steve Hiehn Author

Hey, thanks! I'll take a look for sure! I've found lots of examples of clean CLI (command pattern) style code but am still unconfident on what the recommended server api 'go way' is.