zoobzio January 23, 2026 Edit this page

Overview

fig loads configuration from environment variables, secret providers, and defaults using Go struct tags.

The Idea

Configuration should be declarative. You define what a field needs—its source, its default, whether it's required—and the library handles the rest. No builder chains, no option structs, no multi-step initialization. One function call, predictable resolution order.

The Implementation

fig provides:

  • Struct tag parsingenv, secret, default, and required tags
  • Deterministic resolution — secret → env → default → zero value, every time
  • Secret provider abstraction — plug in Vault, AWS Secrets Manager, GCP Secret Manager, or your own
  • Type conversion — strings, ints, floats, bools, durations, slices, and TextUnmarshaler
  • Validation hooks — implement Validator for post-load checks
  • Nested struct support — automatic recursion into embedded configurations

What It Enables

  • Single-source-of-truth configuration structs
  • Secure secret injection without environment variable sprawl
  • Testable configuration with mock providers
  • Consistent loading across services in a microservices architecture

fig integrates with:

Next Steps