A lightweight helper library for composing modular services in Go applications using dependency injection.
service-composer provides a simple way to structure and compose services in Go applications by leveraging the
do dependency injection container. It helps you organize your application into
manageable modules with clear lifecycle management.
go get github.com/aklinkert/service-composerRequires Go 1.25 or newer.
- Modular Architecture: Organize your application into self-contained modules
- Dependency Injection: Built on top of the
doDI container - Dependency Ordering: Modules declare
DependsOn(); initialization runs in a stable topological order and fails on dependency cycles - Lifecycle Management: Clean startup and shutdown of services
- Minimal Boilerplate: Focus on business logic, not wiring
Documentation and examples can be found in the GoDoc.
Modules may be registered concurrently, but the lifecycle methods (Initialize and Start) are not synchronized and
must be called from a single goroutine once all modules are registered.
For a complete usage example, see example_test.go.
MIT License
Copyright (c) 2025 - present Alex Klinkert