Basic Example
Demonstrates core Rigging features:
- Multi-source loading (YAML + env vars)
- Struct tag validation
- Custom validators
- Secret redaction
- Provenance tracking
Run
go run main.go
# Override with environment variables
export APP_DATABASE__PASSWORD=secret
export APP_ENVIRONMENT=production
go run main.go
Key Points
Struct Tags:
type Config struct {
Port int `conf:"default:8080,min:1024"`
Password string `conf:"required,secret"`
}
Environment Variables: Use __ for nesting
APP_DATABASE__HOST → Database.Host
APP_SERVER__PORT → Server.Port
- Prefix matching is case-insensitive by default (
APP_, app_, App_ all match)
- Set
CaseSensitive: true in sourceenv.Options for exact matching
YAML Keys: Match struct fields (lowercase)
database:
host: localhost
port: 5432
See main README for full documentation.