env: go.pedge.io/env Index | Files

package env

import "go.pedge.io/env"

Package env handles environment variables in a structured manner.

See the README at https://github.com/peter-edge/env-go/blob/master/README.md for more details.


Package Files

decoders.go env.go populate.go

func Main Uses

func Main(do func(interface{}) error, appEnv interface{}, decoders ...Decoder)

Main runs the common functionality needed in a go main function. appEnv will be populated and passed to do, defaultEnv can be nil if there is an error, os.Exit(1) will be called.

func Populate Uses

func Populate(object interface{}, decoders ...Decoder) error

Populate populates an object with environment variables.

The environment has precedence over the decoders, earlier decoders have precedence over later decoders.

type Decoder Uses

type Decoder interface {
    Decode() (map[string]string, error)

Decoder decodes an env file.

func NewEnvFileDecoder Uses

func NewEnvFileDecoder(reader io.Reader) Decoder

NewEnvFileDecoder returns a new Decoder that decodes an env file of the form key=value.

func NewJSONDecoder Uses

func NewJSONDecoder(reader io.Reader) Decoder

NewJSONDecoder returns a new Decoder that decodes a JSON object.

Package env imports 8 packages (graph) and is imported by 9 packages. Updated 2018-02-26. Refresh now. Tools for package owners.