Documentation
¶
Overview ¶
Package nest is a convenience wrapper around Viper providing a way to map configuration values to a struct and it's fields by using annotations.
Index ¶
Constants ¶
View Source
const ( TagIgnored = "ignored" TagDefault = "default" TagRequired = "required" TagSplitWords = "split_words" TagPrefix = "prefix" TagEnvironment = "env" TagFlag = "flag" TagUsage = "usage" )
Tag constants
Variables ¶
View Source
var ( // ErrNotStructPointer is returned when value passed to config.Load() is not a pointer to a struct. ErrNotStructPointer = errors.New("value passed is not a struct pointer") // ErrNotStruct is returned when value passed to config.Load() is not a struct. ErrNotStruct = errors.New("value passed is not a struct") // ErrFlagHelp is returned when the commandline arguments include -h or --help. // Application should exit without an error as pflag handles outputting the manual. ErrFlagHelp = pflag.ErrHelp )
Functions ¶
func Load ¶
func Load(config interface{}) error
Load calls the function with the same name on the global configurator instance.
func SetArgs ¶ added in v0.3.0
func SetArgs(args []string)
SetArgs calls the function with the same name on the global configurator instance.
func SetEnvPrefix ¶
func SetEnvPrefix(prefix string)
SetEnvPrefix calls the function with the same name on the global configurator instance.
Types ¶
type Configurator ¶
type Configurator struct {
// contains filtered or unexported fields
}
func NewConfigurator ¶
func NewConfigurator() *Configurator
func (*Configurator) Load ¶
func (c *Configurator) Load(config interface{}) error
func (*Configurator) SetArgs ¶ added in v0.3.0
func (c *Configurator) SetArgs(args []string)
SetArgs sets the command line arguments.
func (*Configurator) SetEnvPrefix ¶
func (c *Configurator) SetEnvPrefix(prefix string)
SetEnvPrefix manually sets the environment variable prefix.
func (*Configurator) SetName ¶ added in v0.2.0
func (c *Configurator) SetName(name string)
SetName sets the application name for displaying help.
func (*Configurator) SetOutput ¶ added in v0.5.0
func (c *Configurator) SetOutput(output io.Writer)
SetOutput sets the output writer used for help text and error messages.
Click to show internal directories.
Click to hide internal directories.