configo

package module
v0.0.0-...-288b7e8 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2017 License: MIT Imports: 8 Imported by: 9

README

configo

Build Status

Definitive configuration utility in Golang

What

configo gathers configuration parameters from variety of sources,
overlays values by a different env -- production, development, etc -- and merges into a single struct.

Features

It's a set of popular libraries.

Examples

Env vars:

export APP_ENV=production

Dotenv file:

# .env

APP_FOO=foo

Config yaml files:

# config/default.yml

Bar: default
Baz: default?
# config/production.yml

Baz: production

And your config struct...

type Config struct {
	Env string
	Foo string
	Bar string
	Baz string
}

c := Config{}
configo.Load(c, configo.Option{Dir: "./config"})

c.Env //=> "production"
c.Foo //=> "foo"
c.Bar //=> "default"
c.Baz //=> "production"

License

This project is copyright by Creasty, released under the MIT license.
See LICENSE.txt file for details.

Documentation

Index

Constants

View Source
const (
	DEFAULT_CONFIG_ENV  = "development"
	DEFAULT_PREFIX      = "app"
	DEFAULT_DIR         = "."
	DEFAULT_DOTENV_PATH = ".env"
)
View Source
const FILE_GLOB_PATTERN = "%s/**/%s.yml"

Variables

This section is empty.

Functions

func Load

func Load(in interface{}, opt Option) error

Types

type Loader

type Loader struct {
	Option Option
	Struct interface{}
}

func (*Loader) Load

func (self *Loader) Load() error

func (*Loader) LoadEnvVars

func (self *Loader) LoadEnvVars() error

func (*Loader) LoadFiles

func (self *Loader) LoadFiles() error

func (*Loader) PopulateOption

func (self *Loader) PopulateOption()

func (*Loader) Validate

func (self *Loader) Validate() error

type Option

type Option struct {
	ConfigEnv  string
	Prefix     string
	Dir        string
	DotenvPath string
}

Jump to

Keyboard shortcuts

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