Documentation ¶
Overview ¶
Package flagutil contains flag utilities like implementations of flag.Value and flag.Getter interfaces. Also contains methods like ValidateFlags.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RequiredStringFlag ¶
RequiredStringFlag adds a required string flag with the specified name. Note that ValidateFlags must be called to ensure that it is set. Returns a pointer to the string value set. Example usage: var reqstr = flagutil.RequiredStringFlag(name, usage, nil)
func main() { flag.Parse() if err := flagutil.ValidateFlags(nil); err != nil { log.Fatal(err) } log.Println(*reqstr) }
Types ¶
type MultiFlagError ¶
type MultiFlagError []*FlagError
MultiFlagError is a slice of errors returned while validating flags.
func ValidateFlags ¶
func ValidateFlags(fs *flag.FlagSet) MultiFlagError
ValidateFlags validates flags and logs a fatal message with all errors if found. Must be called after flag.Parse(). This is done by calling Get() on all flag values which implement the flag.Getter interface and collecting errors if returned.
func (MultiFlagError) Error ¶
func (m MultiFlagError) Error() string