env

command
v0.0.0-...-bc19bdb Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2016 License: MIT, MIT Imports: 2 Imported by: 0

README

env example

<tmpl,code=go:cat env_all.go>

package main

import (
	"fmt"

	"github.com/jpillora/opts"
)

type Config struct {
	Foo string
	Bar string
}

func main() {

	c := Config{}

	//in this case UseEnv() is equivalent to
	//adding `env:"FOO"` and `env:"BAR"` tags
	opts.New(&c).UseEnv().Parse()

	fmt.Println(c.Foo)
	fmt.Println(c.Bar)
}
``` $ export FOO=hello $ export BAR=world $ go run env_all.go ``` ``` plain hello world ``` ``` $ env --help ``` ``` plain

Usage: env_all [options]

Options: --foo, -f env FOO --bar, -b env BAR --help, -h

</tmpl>

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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