Uber fx (Go)

Application framework for Go providing dependency injection with lifecycle management. Unlike Wire (compile-time, no lifecycle), fx runs at application startup using reflection-based DI — components declare dependencies via function parameters, fx resolves the graph at startup, and manages Start/Stop lifecycle hooks for graceful shutdown. Used internally at Uber for microservices. Ideal for long-running Go agent services needing structured startup/shutdown.

Evaluated Mar 07, 2026 (0d ago) v1.x
Homepage ↗ Repo ↗ Developer Tools go dependency-injection lifecycle uber application-framework open-source
⚙ Agent Friendliness
66
/ 100
Can an agent use this?
🔒 Security
88
/ 100
Is it safe for agents?
⚡ Reliability
86
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
82
Error Messages
80
Auth Simplicity
98
Rate Limits
95

🔒 Security

TLS Enforcement
90
Auth Strength
88
Scope Granularity
85
Dep. Hygiene
90
Secret Handling
88

Local service framework — no network calls. Reflection-based DI doesn't introduce security vulnerabilities. Application security depends on provided components.

⚡ Reliability

Uptime/SLA
85
Version Stability
88
Breaking Changes
85
Error Recovery
85
AF Security Reliability

Best When

You're building production Go agent services needing structured startup, graceful shutdown, and runtime dependency injection — fx's lifecycle hooks prevent common 'service didn't shut down cleanly' bugs.

Avoid When

You want compile-time DI safety without reflection or need maximum startup performance — Wire generates plain Go code with no runtime overhead.

Use Cases

  • Build Go agent service with structured startup — fx resolves all dependencies in correct order and calls OnStart hooks (DB connections, listeners, background workers)
  • Implement graceful shutdown for agent services — register OnStop hooks for clean connection draining without manual lifecycle management
  • Modularize large Go agent applications into fx modules — group related providers into modules that can be included/excluded as needed
  • Use fx for test isolation — fx.Options composition allows swapping real providers with test fakes in integration tests
  • Add health checks and observability to agent services via fx lifecycle hooks that register/deregister health endpoints on startup/shutdown

Not For

  • Compile-time DI with zero runtime overhead — use Wire for generated, zero-reflection DI
  • Simple applications with few dependencies — fx's reflection-based approach adds startup overhead and complexity not needed for small services
  • Teams new to Go DI patterns — fx's Provide/Invoke/Supply API requires understanding DI concepts before the framework becomes productive

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

Library — no external auth. Application DI framework for local service composition.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

MIT-licensed open source from Uber.

Agent Metadata

Pagination
none
Idempotent
Partial
Retry Guidance
Not documented

Known Gotchas

  • fx.Provide() uses reflection — type errors in providers surface at runtime during app.New(), not at compile time; thorough testing of DI configuration is essential
  • fx.Invoke() runs immediately at startup for side-effect functions (registering routes, starting goroutines) — errors in Invoke functions abort startup with clear error messages
  • Circular dependencies cause a panic at startup with a cycle description — redesign the dependency graph; fx cannot resolve cycles even with lazy initialization
  • fx.Lifecycle.Append() OnStop hooks run in reverse registration order — ensure cleanup order matches initialization order by registering in dependency order
  • Using fx in tests requires fx.Options composition — create test modules with fake/mock providers and compose them with real modules for integration testing
  • Large dependency graphs with many providers can make startup errors hard to trace — use fx.WithLogger for verbose dependency resolution logging during development

Alternatives

Full Evaluation Report

Comprehensive deep-dive: security analysis, reliability audit, agent experience review, cost modeling, competitive positioning, and improvement roadmap for Uber fx (Go).

AI-powered analysis · PDF + markdown · Delivered within 30 minutes

$99

Package Brief

Quick verdict, integration guide, cost projections, gotchas with workarounds, and alternatives comparison.

Delivered within 10 minutes

$3

Score Monitoring

Get alerted when this package's AF, security, or reliability scores change significantly. Stay ahead of regressions.

Continuous monitoring

$3/mo

Scores are editorial opinions as of 2026-03-07.

6470
Packages Evaluated
26150
Need Evaluation
173
Need Re-evaluation
Community Powered