flagenv

package module
v0.0.0-...-fcd59fc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2016 License: BSD-3-Clause Imports: 5 Imported by: 66 modules, 80 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

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

func ParseSet

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

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

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址