Documentation ¶
Overview ¶
Package konf provides utilities to work with `github.com/nil-go/konf`
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultLocations ¶
DefaultLocations returns a common set of paths where to look for a configuration file.
- /etc/appName/fileName (on linux and darwin)
- /${HOME}/appName/fileName
- /${HOME}/.appName/fileName
- `pwd`/fileName
func FlagsLoader ¶
FlagsLoader checks the config instance to verify if the defined flags have been set by other providers. If not, default flag values are merged. If they exist, flag values are merged only if explicitly set in the command line.
func PflagsLoader ¶
PflagsLoader checks the config instance to verify if the defined pflags have been set by other providers. If not, default pflag values are merged. If they exist, pflag values are merged only if explicitly set in the command line. The `splitter` value is used to split flag names into nested keys, if not provided the default value "." will be used.
Types ¶
type Config ¶
Config reads configuration from appropriate sources.
To create a new Config, call Setup.
type Option ¶
type Option func(*settings) error
Option instances adjust the behavior of a configuration provider.
func WithEnv ¶
WithEnv adjust the configuration provider to load values from ENV variables. If a `prefix` is provided only ENV variables with it will be evaluated. The provided `prefix` value will be automatically formatted, for example: `myapp` will be evaluated as `MYAPP_`.
func WithFileLocations ¶
WithFileLocations adjust the configuration provider to attempt to load a configuration file form the local filesystem. The first valid configuration file found will be the one used.
func WithPflags ¶
WithPflags loads configuration values coming from "command-line" flags using the `github.com/spf13/pflag` package.
func WithTagName ¶
WithTagName adjust the tag identifier is used when decoding configuration into structs. For example, with the tag name `konf`, it would look for `konf` tags on struct fields. If no value is provided a sane default will be used depending on the configuration file extension.