Skip to content

uber-go/config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

a067eb1 Â· Jan 22, 2024
Jan 22, 2024
Sep 27, 2022
Jun 20, 2018
Jul 12, 2018
Nov 19, 2019
Apr 15, 2020
Jun 20, 2018
Nov 19, 2019
May 17, 2021
Sep 27, 2022
Oct 19, 2018
Jun 20, 2018
Jul 12, 2018
Sep 27, 2022
Jun 20, 2018
Jul 26, 2018
Jul 26, 2018
Jun 20, 2018
Oct 19, 2018
Nov 19, 2019
Jun 20, 2018
Oct 26, 2023
Oct 26, 2023
Jun 20, 2018
Jun 20, 2018
Sep 27, 2022
Jul 6, 2018
Oct 22, 2018
Jun 20, 2018
Mar 15, 2022
Nov 20, 2019

Repository files navigation

🎣 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.