<tmpl,code=go:cat env.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)
}
Usage: env [options]
Options: --foo, -f env FOO --bar, -b env BAR --help, -h
</tmpl>