Documentation
¶
Overview ¶
Package envflag implements support for setting flags through environment variables. Unlike the package standard flag package, a set of top-level wrapper functions are not provided.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var CommandLine = NewFlagSet(flag.CommandLine)
CommandLine is the default set of env flags, backed by the default set of command-line flags. The top-level functions of this package are wrappers for the methods of CommandLine.
Functions ¶
This section is empty.
Types ¶
type FlagSet ¶
type FlagSet struct {
// contains filtered or unexported fields
}
FlagSet represents a set of defined env flags.
func NewFlagSet ¶
NewFlagSet returns a new, empty flag set.
func (*FlagSet) Parse ¶
func (fs *FlagSet) Parse()
Parse parses configuration from environment variables and stores non-empty values. It is recommended to call this after all flags are defined and before flag.FlagSet.Parse.
func (*FlagSet) String ¶
String defines a string flag. A string flag is a single string value, parsed either from an environment variable "<envvarName>" or a command-line argument "-<flagName". The return value is the address of a string variable that stores the value of the flag.
This is a general flag creation utility which is why flagName and envvarName are provided separately rather than generated from a common base.