flagenv: github.com/facebookgo/flagenv Index | Examples | Files

package flagenv

import "github.com/facebookgo/flagenv"

Package flagenv provides the ability to populate flags from environment variables.

Index

Examples

Package Files

flagenv.go

Variables

var Prefix = ""

Specify a prefix for environment variables.

func Parse Uses

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.

Code:

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()

func ParseSet Uses

func ParseSet(prefix string, set *flag.FlagSet) error

ParseSet parses the given flagset. The specified prefix will be applied to the environment variable names.

Package flagenv imports 5 packages (graph) and is imported by 13 packages. Updated 2018-12-20. Refresh now. Tools for package owners.