2
0
2017-12-12 23:18:55 +08:00
2017-12-12 16:00:34 +08:00
2017-12-12 16:00:34 +08:00
2017-12-12 16:00:34 +08:00
2017-12-12 16:00:34 +08:00
2017-12-11 17:14:53 +08:00
2017-12-12 16:00:34 +08:00
2017-12-12 16:00:34 +08:00
2017-12-06 17:11:17 +08:00
2017-12-12 23:18:55 +08:00

Introduction

config is a simple golang library and designed to read configurations from JSON, Yaml files, environment variables and command line. config depends on go-yaml to anlayze Yaml file and use built-in golang library to handle JSON file.

Installation

  1. Install Yaml library first:
go get gopkg.in/yaml.v2
  1. Install config library:
go get github.com/eschao/config

Usage

Defines default values

config library supports defining a default value for structure members by using default keyword in structure tags

  type Database struct {
    Username string `default:"admin"`
    Password string `default:"admin"`
  }

After specified default value in tags, calls config.ParseDefault(interface{}) to set it on structure instance, example codes as the below:

  dbConfig := Database{}
  config.ParseDefault(&dbConfig)
Description
Golang library for reading configurations from JSON, YAML files, environment variables and command line.
Readme 932 KiB
Languages
Go 94.3%
Makefile 4.3%
Shell 0.9%
Awk 0.5%