Yet Another Config provisioning library is strongly inspired by other similar projects, such as olebedev/config, micro/go-config and spf13/viper. Why not use those aforementioned libraries you may ask? You can still use, and that's the point. Sometimes projects start small and a simple YAML configuration file is enough. However, when they grow and you need more features, you may have problems adapting your code to use another library. Through a concise set of interfaces, the main goal of this project is to minimize the impact in your application's code when you need to change configuration provisioning code. Check here for more detail.
- With
go get
:
go get -u github.com/andrealbinop/go-yac
- With dep:
dep ensure -add github.com/andrealbinop/go-yac
-
Load your configuration provider (check here for examples) and retrieve values from it:
-
Retrieve a value from the configuration provider:
loader := ... // build your own config.Loader instance
var err error
var cfg config.Provider
if cfg, err = loader.Load(); err != nil {
// error handling
}
// retrieve a value associated with "key"
value := cfg.String("key")
You can customize config.Provider
property recovering routine, for instance, ignore camel case, as sampled below:
loader := ... // build your own config.Loader instance
var err error
var cfg config.Provider
if cfg, err = loader.Load(); err != nil {
// error handling
} else if defaultLoader, ok := cfg.(provider.Default); ok {
defaultLoader.ValueResolver = // Set Custom ValueResolver Ignored Camel Case
}
- This project follows golang-standards/project-layout project structure.
- It's still in a proof of concept phase, calibrate your expectations.
- Please read mocking section regarding testing with
config
package interfaces.