Our great sponsors
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
-
todo-api-microservice-example
Go microservice tutorial project using Domain Driven Design and Onion Architecture!
Here is a fairly complex project which does just this: https://github.com/krok-o/krok
For my projects I use this code organization (https://github.com/hugdubois/svc-fizzbuzz). I don't necessarily use dependency injection because I consider go packages to be a singleton (with a setup function).
Try fx https://github.com/uber-go/fx. I separate my code into packages in exactly the same way that you want to do and fx takes care of the DI.
I maintain an educational repository that describes the approach I've been taking for building proprietary production-ready services for years, it may or may not satisfy what you're asking for but at least it should give you another approach to think about structuring your service.