Пример #1
0
Файл: db.go Проект: mabetle/mdb
// Config is a interface.
func NewDBConfFromConfig(c mconf.Config) *DBConf {
	logger.Tracef("NewDBConfFromConfig()")
	// check args
	if nil == c {
		logger.Error("Build DBConf error, config is nil")
		return nil
	}

	//load values from location
	host = c.GetStringWithDefault(KEY_HOST, host)
	user = c.GetStringWithDefault(KEY_USER, user)
	password = c.GetStringWithDefault(KEY_PASSWORD, password)
	database = c.GetStringWithDefault(KEY_DATABASE, database)
	port = c.GetStringWithDefault(KEY_PORT, port)
	driver = c.GetStringWithDefault(KEY_DRIVER, driver)
	connVar = c.GetStringWithDefault(KEY_CONN_VAR, connVar)
	return NewDBConf()
}
Пример #2
0
func Demo() {
	var c mconf.Config = mconf.NewConfig(ini.NewIniConfig("../data/demo.ini", "../data/demo2.ini"))
	c.Put("put", "temp put")
	demo.DemoConfig(c)
	fmt.Println(c.GetString("put"))
}
Пример #3
0
// Config api Demo
func DemoConfig(mconf mconf.Config) {
	//should be false
	fmt.Println("IsContain('no-exist'):", mconf.IsContain("no-exist"))
	fmt.Println("GetString('db.spec'):", mconf.GetString("db.spec"))
	fmt.Println("GetString('db2.spec'):", mconf.GetString("db2.spec"))
}