zneix / yec

Golang config library with minimal dependencies

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Yec: YAML-env-config wrapper for Golang

Yec is a simple library that reads data from yaml files and environment variables unmarshaling it into custom structs. It aims to be as lightweight as possible, relying on minimal amount of dependencies, while providing unified functionality between configuration files and environment variables.

Simple example:

package main

import (
	"fmt"

	"github.com/zneix/yec"
)

type myConfig struct {
	BaseURL          string `mapstructure:"base-url"`
	MaxContentLength uint64 `mapstructure:"max-content-length"`
}

func main() {
	y := yec.New("myapplication")
	y.ReadConfig()

	var cfg myConfig
	y.Unmarshal(&cfg)

	fmt.Printf("%# v\n", cfg)
}

Inspired by spf13/viper.

About

Golang config library with minimal dependencies

License:MIT License


Languages

Language:Go 100.0%