golang-uber-fx

Wire and troubleshoot Go applications using uber-go/fx dependency injection.

2|Updated Mar 13, 2023
One-click install
npx skills add https://github.com/haipham22/golang-sample --skill golang-uber-fx-haipham22
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-uber-fx
Source: https://github.com/haipham22/golang-sample/tree/main/.agents/skills/golang-uber-fx
Command: npx skills add https://github.com/haipham22/golang-sample --skill golang-uber-fx-haipham22

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you design, wire, and operate Go applications built with uber-go/fx so startup, shutdown, dependency injection, and module composition stay predictable and maintainable.

Core Features & Use Cases

  • Lifecycle-driven servers: Use fx.Lifecycle hooks to start network listeners and workers without blocking boot.
  • Modern dependency wiring: Apply fx.Provide, fx.Invoke, fx.Annotate, fx.Module, fx.Supply, and fx.Replace to build clean application graphs.
  • Testing and observability: Use fxtest, fx.Populate, and fx.WithLogger to validate wiring, swap fakes, and route fx events through structured logging.
  • Use case: When a Go API grows into multiple concerns like HTTP, database, metrics, and background jobs, this Skill shows how to organize the app into reusable modules and graceful runtime hooks.

Quick Start

Ask for an uber-go/fx wiring example that matches your service, and I will show the correct lifecycle, module, and testing pattern for your case.

Frequently Asked Questions about golang-uber-fx

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I wire Go services with uber-go/fx lifecycle hooks?

Wire Go services with uber-go/fx by applying fx.Provide, fx.Invoke, and fx.Lifecycle to construct application graphs and manage graceful startup or shutdown. This ensures network listeners and workers start without blocking boot.

How do I organize multiple Go API concerns like HTTP and database into reusable fx modules?

Organize Go API concerns into reusable modules using fx.Module, fx.Provide, and fx.Annotate to build clean application graphs. This separates HTTP, database, metrics, and background jobs into predictable, maintainable service compositions.

How does fx.Annotate work for tagged dependencies in Go dependency injection?

fx.Annotate works for tagged dependencies by applying structural annotations to fx.Provide constructors, allowing specific types to be explicitly named and resolved within the dependency injection graph without interface duplication.

What's the best way to test uber-go/fx application wiring and startup?

Test uber-go/fx application wiring using fxtest to validate startup, fx.Populate to swap fakes, and fx.WithLogger to route fx events through structured logging. This verifies dependency graphs execute correctly during testing.

How do I manually start and stop an uber-go/fx application with custom signals?

Manually start and stop uber-go/fx applications using fx.New with fx.Invoke to execute custom startup logic, ensuring graceful signal-aware execution. This allows precise control over application boot and shutdown sequences without blocking.

How do I replace existing dependencies in an uber-go/fx application?

Replace existing dependencies in an uber-go/fx application using fx.Replace to override provided constructors, or fx.Supply to inject existing instances directly. This allows seamless swapping of implementations during testing or module composition.