setting

package
v0.0.0-...-6e56365 Latest Latest
Warning

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

Go to latest
Published: May 14, 2015 License: MIT, MIT Imports: 3 Imported by: 0

README

setting

A simple utility to load your configuration from the environment (with optional defaults)

Circle CI

type Config struct {
  Port string `env:"PORT" default:"3000"`
}

config := new(Config)
setting.Load(config)

// If the PORT environment variable is set, `config.Port` will
// now be its value (`os.Getenv("PORT")`). Otherwise it will
// be "3000"

Both env and default are optional:

type Config struct {
  Name string `env:"NAME"`
  Location struct {
    City string `default:"San Francisco"`
  }
}

config := new(Config)
setting.Load(config)

// `config.Name` will be the NAME environment variable value if
// present, or the zero value if not
// `config.Location.City` will be "San Francisco"

Limitations

Setting currently only supports string type fields! If you need another type open an issue or a pull request 😄

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(config interface{})

Load ...

Types

This section is empty.

Jump to

Keyboard shortcuts

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