envconf

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

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

Go to latest
Published: Oct 26, 2014 License: MIT Imports: 4 Imported by: 256

README

envconf

Configure your Go application from the environment.

Supports most basic Go types and works nicely with the built in flag package.

package main

import(
  "flag"
  "fmt"
  . "github.com/ian-kent/envconf"
)

func main() {
  count := flag.Int("count", FromEnvP("COUNT", 15).(int), "Count target")
  flag.Parse()
  for i := 1; i <= *count; i++ {
    fmt.Printf("%d\n", i)
  }
}

Licence

Copyright ©‎ 2014, Ian Kent (http://iankent.uk).

Released under MIT license, see LICENSE for details.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnsupportedType is returned if the type passed in is unsupported
	ErrUnsupportedType = errors.New("Unsupported type")
)

Functions

func FromEnv

func FromEnv(env string, value interface{}) (interface{}, error)

FromEnv returns the environment variable specified by env using the type of value

func FromEnvP

func FromEnvP(env string, value interface{}) interface{}

FromEnvP is the same as FromEnv, but panics on error

Types

This section is empty.

Jump to

Keyboard shortcuts

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