Ejemplo n.º 1
0
func loadConfig() {
	initparse.DefaultParse(ConfigPath)
	section, ok := initparse.GetSection("ChargeDB")
	if ok {
		DBUser, _ = section.GetValue("DBUser")
		DBPassword, _ = section.GetValue("DBPassword")
		DBAddress, _ = section.GetValue("DBAddress")
		DBPort, _ = section.GetValue("DBPort")
		DBSchema, _ = section.GetValue("DBSchema")
	}
}
Ejemplo n.º 2
0
func Init() {
	initparse.DefaultParse("./config.cfg")
	if section, ok := initparse.GetSection("Auth"); ok {
		accountId = section.GetIntValue("accountId")
		accountSession, _ = section.GetValue("accountSession")
		log.Debugf("Load [auth] config accountId [%d] accountSession [%s]", accountId, accountSession)
	}
	if section, ok := initparse.GetSection("Server"); ok {
		server_url, _ = section.GetValue("server_url")
		log.Debugf("Load [Server] config server_url [%s]", server_url)
	}
}
Ejemplo n.º 3
0
func loadConfig() {
	initparse.DefaultParse("./config.cfg")

	if paths, ok := initparse.GetSection("Path"); ok {
		excelRoot, _ = paths.GetValue("excelRoot")
		exportRoot, _ = paths.GetValue("exportRoot")
	}
	//load filter
	filterMap["default"] = &excelFilter{"default", -1, -1, -1, -1}
	for i := 1; i < 1024; i++ {
		sectionName := "Filter" + fmt.Sprintf("%d", i)
		if filters, ok := initparse.GetSection(sectionName); ok {
			filename, _ := filters.GetValue("filename")
			rBegin := filters.GetIntValue("rBegin")
			rEnd := filters.GetIntValue("rEnd")
			cBegin := filters.GetIntValue("cBegin")
			cEnd := filters.GetIntValue("cEnd")

			filterMap[filename] = &excelFilter{filename, cBegin, cEnd, rBegin, rEnd}
		} else {
			break
		}
	}
	//load db conn
	for i := 1; i < 1024; i++ {
		sectionName := "DB" + fmt.Sprintf("%d", i)
		if connSection, ok := initparse.GetSection(sectionName); ok {
			connStr, ok := connSection.GetValue("ConnStr")
			fmt.Printf("Connect db [%s]\n", connStr)
			if !ok {
				fmt.Printf("[Warning] Section %s has no property ConnStr\n", sectionName)
				continue
			}
			sqlconn, err := sql.Open("mysql", connStr)
			if err != nil {
				fmt.Printf("[Warning] Error in open sql conn [%s]\n", connStr)
				continue
			}
			conns = append(conns, sqlconn)
		} else {
			break
		}
	}
}