Documentation
¶
Overview ¶
Package config provides configuration loader and the interface for working with configuration.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrShouldStop is returned when the execution should be stopped. E.g. on -v and -h flags. ErrShouldStop = errors.New("execution should be stopped") )
Additional errors to control the execution flow.
Functions ¶
This section is empty.
Types ¶
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader is a viper config loader.
func NewLoader ¶
NewLoader returns a new viper loader.
name is the short name of the service, as well as the name of the root command.
short and long are the short and long descriptions of the service for the root command.
configPath is the path to the configuration file.
envPrefix is the prefix for environment variables.
func (*Loader) Load ¶
func (l *Loader) Load(cfg ServiceConfig, printVersion func(io.Writer) error, writer io.Writer) (ServiceConfig, error)
Load loads configuration from a file and environment variables. It checks the flags in the process and executes the root command, depending on the flag. If no additional flags are set, it will load the configuration from the path provided.
If -h (--help) or -v (--version) flags are set, it will return nil, ErrShouldStop as a signal to stop the execution.