Documentation
¶
Overview ¶
Package flagenv provides the ability to populate flags from environment variables.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Prefix = ""
Specify a prefix for environment variables.
Functions ¶
func Parse ¶
func Parse()
Parse will set each defined flag from its corresponding environment variable . If dots or dash are presents in the flag name, they will be converted to underscores.
If Parse fails, a fatal error is issued.
Example ¶
package main
import (
"flag"
"github.com/facebookgo/flagenv"
)
func main() {
var raz string
flag.StringVar(&raz, "raz-value", "bar", "set the raz")
// override default flag value with value found in MY_RAZ_VALUE
flagenv.Prefix = "my_"
flagenv.Parse()
// override value found in MY_RAZ_VALUE with command line flag value -raz-value=foo
flag.Parse()
}
Output:
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.
