cconf - Go config library.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
testdata
.editorconfig
.travis.yml
LICENSE
README.md
conf.go
conf_test.go
json.go
populate.go

README.md

cconf

MIT licensed

Introduction

CConf is a Go package for handling configurations in Go applications. cconf references ozzo-config, but higher performance.

Download & Install

go get github.com/syyongx/cconf

Features

  1. Loading configuration file, default JSON.
  2. Dynamic setting configuration.

Requirements

Go 1.2 or above.

Quick Start

import github.com/syyongx/cconf

func main() {
    c := cconf.New()
    age := c.GetInt("age", 18)
    name := c.Get("name").(string)
    c.Set("email", "default@default.com")
    email := c.GetString("email")
}

Apis

New() *Conf
RegisterLoadFunc(typ string, fn loadFunc)
Load(files ...string) error
LoadWithPattern(pattern string) error

Set(key string, val interface{}) error
Get(key string, def ...interface{}) interface{}
GetString(key string, def ...string) string
GetInt(key string, def ...int) int
GetInt64(key string, def ...int64) int64
GetFloat(key string, def ...float64) float64
GetBool(key string, def ...bool) bool

SetStore(data ...interface{})
GetStore() interface{}

Register(name string, provider interface{}) error
Populate(v interface{}, key ...string) (err error)

LICENSE

cconf source code is licensed under the MIT Licence.