This stable version
$ go get github.com/mantyr/conf
package main
import (
"github.com/mantyr/conf"
"github.com/mantyr/conf/confdb"
"flag"
)
func init() {
dir := flag.String("dir", "", "Directory of program")
flag.Parse()
conf.SetDirBin(*dir) // Set DirBin and SetDefaultCatalog(conf.DirBin+"/configs")
conf.SetDefaultCatalog("./testdata") // Set custom DirConfig, no change conf.DirBin, default value conf.DirBin = "."
conf.SetDefaultFile("properties")
// preload files, not necessary
conf.LoadFile("properties")
conf.LoadFile("storage")
// connect to db "section \"default\"" from storage.ini
confdb.ConnectDB("default")
}
func main() {
val := conf.Get("key")
val = conf.Get("key", "default")
val = conf.Get("key", "default", "properties")
val_int := conf.GetInt64("key")
val_int = conf.GetInt64("key", "default")
val_int = conf.GetInt64("key", "default", "properties")
section := conf.GetSection("section_name")
section = conf.GetSection("section_name", "properties")
val = section.Get("key")
val_int = section.GetInt("key")
val_int64 = section.GetInt64("key")
ini_file := conf.GetFile("properties")
...
db := confdb.GetDB("default")
db = confdb.GetDB() // alias for confdb.GetDB("default")
}