Wire generates code at compile time, fx manages dependencies at runtime, and dig analyzes dependency graphs.
Wire, fx, and dig are not DI frameworks; they are distinct tools for dependency injection (fx, wire) and graph analysis (dig) within the Go ecosystem. Use dig for graph traversal, wire for compile-time code generation, or fx for runtime composition with lifecycle management.
// dig: Graph analysis
import "github.com/uber-go/dig"
// wire: Compile-time generation
//go:generate wire
// fx: Runtime composition
import "go.uber.org/fx"
Think of these as different ways to manage how your Go program's parts connect. Dig is like a map that checks if your connections make sense. Wire is a tool that writes the connection code for you before you even run the program. Fx is a manager that connects everything together while your program is running and handles starting and stopping services.