Configuration for Go applications
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
internal YAML: support non-string scalar keys (#105) Oct 17, 2018
testdata Replace provider and value implementations (#87) Jun 20, 2018
.codecov.yml Lower coverage target to 90% (#96) Jul 12, 2018
.gitignore Add gitignore May 23, 2017
.travis.yml Add an internal package for unreachable errors (#79) Jun 5, 2018
CHANGELOG.md Prepare for v1.3.1 (#107) Oct 22, 2018
LICENSE.txt Replace provider and value implementations (#87) Jun 20, 2018
Makefile Small Makefile cleanups (#82) Jun 5, 2018
README.md Update changelog and readme (#88) Jun 28, 2018
config.go Re-expand env vars in WithDefault (#103) Oct 19, 2018
config_ext_test.go Re-expand env vars in WithDefault (#103) Oct 19, 2018
config_test.go Replace provider and value implementations (#87) Jun 20, 2018
constructors.go NewProviderGroup: Handle empty sources correctly (#95) Jul 12, 2018
doc.go Add documentation re: quoted strings (#94) Jul 6, 2018
equal.go Replace provider and value implementations (#87) Jun 20, 2018
escape.go Add an option for unexpanded sources (#97) Jul 26, 2018
escape_test.go Add an option for unexpanded sources (#97) Jul 26, 2018
example_test.go Replace provider and value implementations (#87) Jun 20, 2018
expand.go Re-expand env vars in WithDefault (#103) Oct 19, 2018
expand_test.go Remove parallelization from expansion tests (#84) Jun 5, 2018
glide.lock Replace provider and value implementations (#87) Jun 20, 2018
glide.yaml Replace provider and value implementations (#87) Jun 20, 2018
nop.go Replace provider and value implementations (#87) Jun 20, 2018
nop_test.go Replace provider and value implementations (#87) Jun 20, 2018
option.go Re-expand env vars in WithDefault (#103) Oct 19, 2018
option_test.go Handle empty and null sources correctly (#93) Jul 6, 2018
provider.go Minor documentation improvement to Provider (#106) Oct 22, 2018
static_test.go Replace provider and value implementations (#87) Jun 20, 2018
version.go Re-expand env vars in WithDefault (#103) Oct 19, 2018

README.md

🎣 config GoDoc Build Status Coverage Status

Convenient, injection-friendly YAML configuration.

Installation

go get -u go.uber.org/config

Note that config only supports the two most recent minor versions of Go.

Quick Start

// Model your application's configuration using a Go struct.
type cfg struct {
    Parameter string
}

// Two sources of configuration to merge.
base := strings.NewReader("module: {parameter: foo}")
override := strings.NewReader("module: {parameter: bar}")

// Merge the two sources into a Provider. Later sources are higher-priority.
// See the top-level package documentation for details on the merging logic.
provider, err := config.NewYAML(config.Source(base), config.Source(override))
if err != nil {
    panic(err) // handle error
}

var c cfg
if err := provider.Get("module").Populate(&c); err != nil {
  panic(err) // handle error
}

fmt.Printf("%+v\n", c)
// Output:
// {Parameter:bar}

Development Status: Stable

All APIs are finalized, and no breaking changes will be made in the 1.x series of releases. Users of semver-aware dependency management systems should pin config to ^1.


Released under the MIT License.