cconf icon indicating copy to clipboard operation
cconf copied to clipboard

CConf - Go config library.

CConf

GoDoc Go Report Card 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", "[email protected]")
    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.