A Go library for injecting configuration values into structs from environment variables, flags, JSON files, or default tags.
Configuration is a Go library that injects values into struct fields from various sources like environment variables, command-line flags, JSON files, or default tags. It solves the problem of scattered configuration logic by centralizing it within a single struct model, making configuration management more declarative and maintainable.
Go developers building applications that require flexible, multi-source configuration management, particularly those following 12-factor app principles or working on CLI tools and services.
Developers choose Configuration for its simplicity, extensibility, and zero-dependency design. It offers a clean, tag-based approach to defining configuration metadata directly in structs, with customizable provider priorities and support for custom types.
Library for setting values to structs' fields from env, flags, files or default tag
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
The library has no external dependencies, keeping it lightweight and easy to integrate, which aligns with the README's emphasis on 12-factor app principles.
Providers execute in defined order, with the first successful source setting the value, allowing precise control over configuration precedence as demonstrated in the Quick Start example.
Custom providers can be implemented via a simple interface, enabling support for bespoke data sources beyond built-in options like environment variables and JSON files.
Handles primitives, slices, pointers, embedded structs, and custom types through the FieldSetter interface, covering a wide range of Go data structures as listed in the Supported Types section.
Relies heavily on reflection for setting struct fields, which can introduce performance overhead compared to compile-time or code-generated configuration approaches.
While it supports type conversion via FieldSetter, advanced validation like range checks or complex rules must be implemented separately, adding extra development effort.
Support for common formats like YAML requires a separate, external provider module ('configuration-yaml-file'), increasing setup complexity and dependency management.