env

package
v0.0.0-...-d7157a5 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2014 License: Apache-2.0, MIT Imports: 3 Imported by: 0

README

env

Easy environment variables for Go

Usage

import "github.com/darkhelmet/env"

...

s := env.String("USER") // Will panic if USER is not present
sd := env.StringDefault("KEY", "It-Not-Present")
sdf := env.StringDefaultF("KEY", func() string { return "do something tough" })

// Similarly for int and float

env.Int("N") // Panic if not present
env.IntDefault("N", 1)
env.IntDefaultF("N", func() int { return 5 })

env.Float("F") // Panic if not present
env.FloatDefault("F", 1.0)
env.FloatDefaultF("F", func() float { return 5.5 })

License

Apache 2.0, see LICENSE.md

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Float

func Float(key string) float64

Get a float from the environment, panicking if it's not present or doesn't parse properly

func FloatDefault

func FloatDefault(key string, def float64) (val float64)

Get a float from the environment, returning the default if it's not present or doesn't parse properly

func FloatDefaultF

func FloatDefaultF(key string, def func() float64) (val float64)

Get a float from the environment, returning the result of the default function if it's not present or doesn't parse properly

func Int

func Int(key string) int

Get an int from the environment, panicking if it's not present or doesn't parse properly

func IntDefault

func IntDefault(key string, def int) (val int)

Get an int from the environment, returning the default if it's not present or doesn't parse properly

func IntDefaultF

func IntDefaultF(key string, def func() int) (val int)

Get an int from the environment, returning the result of the default function if it's not present or doesn't parse properly

func String

func String(key string) string

Get a string from the environment, panicking if it's not there

func StringDefault

func StringDefault(key, def string) (val string)

Get a string from the environment, returning the default if it's not present

func StringDefaultF

func StringDefaultF(key string, def func() string) (val string)

Get a string from the environment, returning the result of the default function if it's not present

Types

This section is empty.

Jump to

Keyboard shortcuts

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