Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddConfigFile ¶
func AddConfigFile(path ...string)
AddConfigFile adds one or more config file(s) (WITHOUT THE FILE EXTENTION) to try to load a startup. Supports JSON (.json), TOML (.toml) and YAML (.yaml) configuration files. Config files are tried in order they are added and the search stop at the first existing file.
func Parse ¶
func Parse(v interface{})
Parse parses the struct to build the flags, parse/decode the optional config file, decode the environment variables and finally parse the arguments.
func SetConfigFileFlag ¶
SetConfigFileFlag adds a config file flag
func SetEnvPrefix ¶
func SetEnvPrefix(prefix string)
SetEnvPrefix defines a prefix that ENVIRONMENT variables will use. If the prefix is "xyz", environment variables must start with "XYZ_".
Types ¶
type Duration ¶ added in v1.1.0
Duration wraps time.Duration so we can augment it with encoding.TextMarshaler and flag.Value interfaces.
func (*Duration) UnmarshalText ¶ added in v1.1.0
UnmarshalText unmarshals a byte slice into a Duration value.
type ErrHandling ¶
type ErrHandling int
ErrHandling defines how to handle parsing errors
const ( // ContinueOnError will return an err from Parse() if an error is found ContinueOnError ErrHandling = iota // ExitOnError will call os.Exit(2) if an error is found when parsing ExitOnError // PanicOnError will panic() if an error is found when parsing flags PanicOnError )
type Gofig ¶
type Gofig struct {
// contains filtered or unexported fields
}
Gofig is the main gofig structure
func (*Gofig) AddConfigFile ¶
AddConfigFile adds one or more config file(s) (WITHOUT THE FILE EXTENTION) to try to load a startup. Supports JSON (.json), TOML (.toml) and YAML (.yaml) configuration files. Config files are tried in order they are added and the search stop at the first existing file.
func (*Gofig) Parse ¶
Parse parses the struct to build the flags, parse/decode the optional config file, decode the environment variables and finally parse the arguments.
func (*Gofig) ParseWithArgs ¶
ParseWithArgs parses the struct to build the flags, parse/decode the optional config file, decode the environment variables and finally parse the arguments.
func (*Gofig) SetConfigFileFlag ¶
SetConfigFileFlag adds a config file flag
func (*Gofig) SetEnvPrefix ¶
SetEnvPrefix defines a prefix that ENVIRONMENT variables will use. If the prefix is "xyz", environment variables must start with "XYZ_".