A minimalist Go library for loading configuration from files and environment into structs with validation and defaults.
Fig is a lightweight Go library that loads application configuration into Go structs. It simplifies configuration management by allowing developers to define configuration, validations, and defaults within a single struct using struct tags, supporting multiple file formats and environment variables.
Go developers building applications that require structured, type-safe configuration management, particularly those needing to load settings from files and environment variables with validation and defaults.
Developers choose fig for its simplicity and minimalism, offering a clean, type-safe way to manage configuration without unnecessary complexity, with only three external dependencies and support for decoding strings into complex types like Time, Duration, and Regexp.
A minimalist Go configuration library
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Allows defining config, defaults, and validations in a single struct using tags, as shown in the README example with struct fields like 'validate:required' and 'default' values.
Supports loading from YAML, JSON, TOML files and environment variables with precedence handling, using the UseEnv option to integrate env vars seamlessly.
Decodes strings into complex Go types like time.Time and regexp.Regexp automatically, leveraging Go's StringUnmarshaler interface for custom types.
Has only three external dependencies, keeping the library lightweight and reducing bloat, which is emphasized in the README as a key philosophy.
Only handles files and environment variables; lacks built-in support for remote configuration sources or dynamic reloading, which might require additional tooling.
Validation is limited to required fields via tags; more complex rules or custom validators are not natively supported, unlike libraries with richer validation ecosystems.
Does not include features to watch for changes in configuration files and reload automatically, a common need in dynamic environments for zero-downtime updates.