env

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2018 License: AGPL-3.0 Imports: 6 Imported by: 0

README

Package env provides a convenient way to initialize
variables from the environment.

Documentation

Overview

Package env provides a convenient way to convert environment variables into Go data. It is similar in design to package flag.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(name string, value bool) *bool

Bool returns a new bool pointer. When Parse is called, env var name will be parsed and the resulting value will be assigned to the returned location. Parsing uses strconv.ParseBool.

func BoolVar

func BoolVar(p *bool, name string, value bool)

BoolVar defines a bool var with the specified name and default value. The argument p points to a bool variable in which to store the value of the environment variable.

func Duration

func Duration(name string, value time.Duration) *time.Duration

Duration returns a new time.Duration pointer. When Parse is called, env var name will be parsed and the resulting value will be assigned to the returned location.

func DurationVar

func DurationVar(p *time.Duration, name string, value time.Duration)

DurationVar defines a time.Duration var with the specified name and default value. The argument p points to a time.Duration variable in which to store the value of the environment variable.

func Int

func Int(name string, value int) *int

Int returns a new int pointer. When Parse is called, env var name will be parsed and the resulting value will be assigned to the returned location.

func IntVar

func IntVar(p *int, name string, value int)

IntVar defines an int var with the specified name and default value. The argument p points to an int variable in which to store the value of the environment var.

func Parse

func Parse()

Parse parses known env vars and assigns the values to the variables that were previously registered. If any values cannot be parsed, Parse prints an error message for each one and exits the process with status 1.

func String

func String(name string, value string) *string

String returns a new string pointer. When Parse is called, env var name will be assigned to the returned location.

func StringSlice

func StringSlice(name string, value ...string) *[]string

StringSlice returns a pointer to a slice of strings. It expects env var name to be a list of items delimited by commas. If env var name is missing, StringSlice returns a pointer to a slice of the value strings.

func StringSliceVar

func StringSliceVar(p *[]string, name string, value ...string)

StringSliceVar defines a new string slice with the specified name. The argument p points to a string slice variable in which to store the value of the environment var.

func StringVar

func StringVar(p *string, name string, value string)

StringVar defines a string with the specified name and default value. The argument p points to a string variable in which to store the value of the environment var.

func URL

func URL(name string, value string) *url.URL

URL returns a new url.URL pointer. When Parse is called, env var name will be parsed and the resulting value will be assigned to the returned location. URL panics if there is an error parsing the given default value.

func URLVar

func URLVar(p *url.URL, name string, value string)

URLVar defines a url.URL variable with the specified name ande default value. The argument p points to a url.URL variable in which to store the value of the environment variable.

Types

This section is empty.

Jump to

Keyboard shortcuts

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