Configuration parser for Go.
- Read and merge configuration values from environment variables, stdin and files.
- Generate JSON schema for configuration struct based on types and tags.
- Apply default values for configuration values.
- Support for JSON, YAML and Gob.
go get github.com/jfk9w-go/confi@latest
Command-line options
Option | Description |
---|---|
--config.stdin=<codec> |
Read configuration from stdin. Supported codecs: yaml or yml , json , gob . |
--config.file=<path> |
Read configuration from file. Option may be used several times in order to pass multiple files. Codec is resolved based on filename extension. See supported codecs above. |
Environment variables
Environment variables are filtered based on prefix passed to confi.Get()
call.
A single configuration file may be specified via <prefix>_CONFIG_FILE
environment variable.
Priority
When properties are specified in multiple ways (e.g. environment variable and CLI option), they have the following priority:
- CLI options.
- Configuration files.
- Environment variables.
Arrays (slices) and maps are overridden as a whole.
TODO