Struct Tags In, Configuration Out. One Call. Done.

Load configuration from secrets, environment variables, and defaults using struct tags. No config files, no YAML, no builder patterns — just fig.Load(&cfg).

Get Started
import "github.com/zoobz-io/fig"

type Config struct {
    // Resolution order: secret → env → default → zero value
    DBPassword string        `secret:"db/pass" env:"DB_PASSWORD" default:"changeme"`
    Host       string        `env:"APP_HOST" default:"localhost"`
    Port       int           `env:"APP_PORT" default:"8080"`
    APIKey     string        `env:"API_KEY" required:"true"`
    Timeout    time.Duration `env:"TIMEOUT" default:"30s"`
    Tags       []string      `env:"APP_TAGS"`
}

func (c *Config) Validate() error {
    if c.Port < 1 || c.Port > 65535 {
        return errors.New("port out of range")
    }
    return nil
}

// One call. Secrets checked first, then env, then defaults.
provider, _ := vault.New()
var cfg Config
fig.Load(&cfg, provider)
90%Test Coverage
A+Go Report
MITLicense
1.24.0+Go Version
v0.0.3Latest Release

Why Fig?

Configuration loading that fits in your head.

Deterministic Resolution

Secret → env → default → zero value. Every time, same order, no ambiguity. The most secure source wins.

Declarative Struct Tags

Requirements live with the fields they configure. One place to read, one place to change.

Pluggable Secret Providers

One method interface. Vault, AWS Secrets Manager, GCP Secret Manager — or write your own in five lines.

Validation Hooks

Implement Validate() for cross-field checks, range validation, and business logic after all fields are populated.

Cached Metadata

Struct tag parsing via sentinel is cached after first load. Reflection cost paid once per type, not per call.

Nested Struct Recursion

Embedded structs descended automatically. Build hierarchical configs naturally without extra boilerplate.

Capabilities

Secrets, environment variables, defaults, validation, and type conversion — all through struct tags.

FeatureDescriptionLink
Environment Bindingenv:"VAR_NAME" reads from os.Getenv. Empty strings fall through to the next source in the resolution chain.Quickstart
Secret ProvidersMinimal interface for pluggable backends. Built-in providers for Vault, AWS Secrets Manager, and GCP Secret Manager.Secret Providers
Default Valuesdefault:"value" provides sensible fallbacks parsed with the same type conversion as env and secrets.Concepts
Required Fieldsrequired:"true" fails Load if no value from any source. Clear error messages with field context.Troubleshooting
Type ConversionPrimitives, durations, slices, pointers, and any encoding.TextUnmarshaler. Extensible via UnmarshalText.Types
Cloud IntegrationsSeparate modules for HashiCorp Vault KV v2, AWS Secrets Manager, and GCP Secret Manager.Vault

Articles

Browse the full fig documentation.

Learn

OverviewConfiguration loading from struct tags with secret provider support
QuickstartGet productive with fig in minutes
ConceptsCore abstractions and mental models for fig
ArchitectureInternal implementation details and design decisions

Guides

TestingHow to test code that uses fig
TroubleshootingCommon errors, edge cases, and debugging strategies
ValidationCustom validation patterns with the Validator interface
Secret ProvidersImplementing and using custom secret providers

Integrations

HashiCorp VaultUsing fig with HashiCorp Vault KV secrets engine
AWS Secrets ManagerUsing fig with AWS Secrets Manager
GCP Secret ManagerUsing fig with Google Cloud Secret Manager

Reference

API ReferenceComplete API documentation for fig
Types ReferenceError types, supported types, and type conversion