Package envflag
Overview
Package envflag sets command-line flags from environment variables, so a service can be configured either way: flags for development, and the environment in a container.
Index
Functions
Name source
func Name(prefix, flagName string) stringName returns the environment variable for a flag: the prefix, then the flag's name in capitals with "-" as "_". The flag "dns-timeout" with the prefix "WHATSMYIP_" is WHATSMYIP_DNS_TIMEOUT.
Set source
func Set(fs *flag.FlagSet, prefix string, getenv func(string) string) errorSet sets each of fs's flags whose environment variable is set and not empty, using getenv (usually os.Getenv). Call it before fs.Parse, so a flag on the command line overrides its variable. It returns an error naming the variable if a value is invalid.