What problem does it solve?
It solves brittle and error-prone Go application wiring by providing a structured dependency injection approach with lifecycle management for long-running services.
Core Features & Use Cases
- Lifecycle-first boot and graceful shutdown: model startup and teardown with fx.Lifecycle hooks (OnStart/OnStop) instead of constructor side effects.
- Modular composition with fx.Module: organize providers, invokes, and decorators into reusable units that scale with large codebases.
- Robust DI ergonomics: use fx.Provide, fx.Invoke, fx.Annotate, value groups, named/grouped bindings, and signal-aware Run behavior.
- Structured fx event logging and testing support: integrate fx.WithLogger and test wiring with fxtest, fx.Populate, and fx.Replace.
Quick Start
Have the AI generate an uber-go/fx composition root that wires constructors with fx.New, registers at least one fx.Invoke to force construction, and starts a server in an fx.Lifecycle OnStart hook while shutting it down in OnStop.