简单地读取不同环境的配置, 目前仅限于YAML
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
liangzy 8d7803d99d 1.二级节点直接解释字符串优化 il y a 3 ans
conf 1.写文档 il y a 3 ans
.gitignore new project il y a 4 ans
README.md 1.写文档 il y a 3 ans
grconfig.go 1.二级节点直接解释字符串优化 il y a 3 ans
grconfig_test.go 1.二级节点直接解释字符串优化 il y a 3 ans
ini.go new project il y a 4 ans
json.go new project il y a 4 ans
xml.go new project il y a 4 ans
yaml.go 1.二级节点直接解释字符串优化 il y a 3 ans

README.md

grconfig

使用方法直接看 grconfig_test.go

import "golib.gaore.com/GaoreGo/grconfig"
type Dsn struct {
    User   string `yaml:"user"`
    Pass   string `yaml:"pass"`
    Host   string `yaml:"host"`
    Port   int    `yaml:"port"`
    Name   string `yaml:"name"`
    Driver string `yaml:"driver"`
    Prefix string `yaml:"prefix"`
}

var items = make(map[string]*Dsn)

// 一级
gr := New("conf/")
fmt.Println(gr.Item("db", &items))
fmt.Printf("%+v\n", items["default"])

// 二级
a := new(Dsn)
gr.Item("db.default", &a)
fmt.Printf("%+v\n", a)

// 解释字符串
fmt.Println("直接解释字符串", gr.String("db.default.host"))

// item形式解释符串
var s string
gr.Item("db.default.host", &s)
fmt.Println("item形式解释符串:", s)