Helpers useful for configuring Go structs.
Original conceived to provide alternative ways for configuring experiments in evo, this package exists outside that library for two reasons:
- To keep the evo library itself as independent as possible
- To provide this functionality without requiring the full evo source
To start using the config library, install Go and run go get
:
$ go get github.com/klokare/config/...
Each helper provides its own New method(s). Some rely on an io.Reader for the source configuration, others might use environment variables, SQL databases, or key-value stores. Once instantiated, though, the use will be the same:
// Create the new configurer
var cfg *json.Configurer
if cfg, err = json.NewFromFile("example.json"); err != nil {
...
}
// Configure other components
var baker Baker
var butcher Butcher
var maker candlestick.Maker
if err = cfg.Configure(&baker, &butcher, &maker); err != nil {
...
}