go_yac

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2019 License: MIT Imports: 7 Imported by: 0

README

go-yac GoDoc Build Status Coverage Status Go Report

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.

Installation

  • With go get:
go get -u github.com/andrealbinop/go-yac
dep ensure -add github.com/andrealbinop/go-yac

Usage

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")

Custom Property Recovery

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
}

Development Notes

Documentation

Overview

Package go_yac is a configuration provisioning toolkit, inspired by other libraries such as viper, go-config, among others.

go_yac contains the following packages:

The composite package allows composing hierarchically config.Loader and config.Provider implementations.

The config package provides a cohesive set of interfaces to expose configuration provisioning features.

The loader package contains useful implementations for config.Loader interface, relying only on go stdlib.

The logger package provides a stdlib log compatible interface and mechanisms to easily swap implementations.

The provider package offers a default config.Repository backed implementation for config.Provider.

The reader package contains useful implementations for loader.Reader interface, relying only on go stdlib.

The yaml package provides a go-yaml based loader.Parser implementation

Directories

Path Synopsis
examples
internal
samples
Package samples helps this project's tests, providing filesystem assets
Package samples helps this project's tests, providing filesystem assets
pkg
composite
Package composite allows composition of config.Loader Package composite allows composition of config.Provider sources hierarchically.
Package composite allows composition of config.Loader Package composite allows composition of config.Provider sources hierarchically.
config
Package config holds main interfaces and constants to interact with configuration provisioning
Package config holds main interfaces and constants to interact with configuration provisioning
loader
Package loader provides reading configuration from streamable data Package loader provides reading configuration from os environment
Package loader provides reading configuration from streamable data Package loader provides reading configuration from os environment
logger
Package logger provides an interfaces used to log configuration provisioning default implementations.
Package logger provides an interfaces used to log configuration provisioning default implementations.
parser/yaml
Package yaml parses yaml data to be used by map configuration databases
Package yaml parses yaml data to be used by map configuration databases
provider
Package provider contains default implementations from config.Provider interface
Package provider contains default implementations from config.Provider interface
repository
Package repository with a map[string]interface{} backed config.Repository implementation
Package repository with a map[string]interface{} backed config.Repository implementation

Jump to

Keyboard shortcuts

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