Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidStruct = errors.New("configuration must be a struct pointer")
ErrInvalidStruct indicates that a configuration struct is not the correct type.
Functions ¶
func ParseWithArgs ¶
ParseWithArgs parses configuration into the provided struct, returning the remaining args after flag parsing
Types ¶
type Option ¶
type Option func(c *context)
Option represents a change to the default parsing
func WithConfigFile ¶
WithConfigFile tells parse to attempt to read from the specified file, if it is found.
func WithConfigFileFlag ¶
WithConfigFileFlag tells parse to look for a flag called `flagname` and, if it is found, to attempt to load configuration from this file. If the flag is specified, it will override the value provided to WithConfigFile, if that has been specified. If the file is not found, the program will exit with an error.
func WithSource ¶
WithSource adds additional configuration sources for configuration parsing
type Setter ¶
Setter is implemented by types can self-deserialize values. Any type that implements flag.Value also implements Setter.
type Source ¶
type Source interface { // Get takes a location specified by a key and returns a string and whether // or not the value was set in the source Get(key []string) (value string, found bool) }
Source represents a source of configuration data. Sources requiring the pre-fetching and processing of several values should ideally be lazily- loaded so that sources further down the chain are not queried if they're not going to be needed.