Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultMap = newDefaultMap()
DefaultMap is default variable mapping function, it replaces hyphens with underscores and upper-cases the result.
Example: connect-timeout => CONNECT_TIMEOUT.
Functions ¶
func Parse ¶
func Parse(opts ...Option)
Parse should be used in place of `flag.Parse()` to add support of environment variables to the default command-line flags parser.
func ParseWithEnv ¶
ParseWithEnv enables environment variables support for the given flag set. It adds environment variable names to each value usage string. Values from the environment only applied when flag hasn't been set from the command-line arguments and the value is not empty.
Panics when fs is already parsed.
Types ¶
type MapFunc ¶
MapFunc maps flag names to environment variable names.
If returned value is an empty string the flag is ignored.
type Option ¶
type Option func(*parser)
Option is a parser configuration option.
func WithLookupEnv ¶ added in v0.4.0
WithLookupEnv changes the default function that retrieves environment variables.
Default is os.LookupEnv.