知行学院重新架构Golang版后台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
688 B

package config
import (
"main_exam_server/loges"
"github.com/go-ini/ini"
)
var (
MysqlConfig = &mysqlConfig{}
)
//加载数据库配置
func LoadDataBaseConfig(dataPath string, dataName string) (err error) {
loges.LongInit("开始加载Mysql基础配置...")
dataBaseSetUp, err := ini.Load(dataPath)
if err != nil {
loges.LongInit("数据库配置加载失败!")
return err
}
err = dataBaseSetUp.Section(dataName).MapTo(MysqlConfig)
if err != nil {
loges.LongInit("数据库配置加载失败!")
return err
}
// allsec := dataBaseSetUp.SectionStrings()
// fmt.Println("sections: ", allsec)
loges.LongInit("数据库配置全部加载完成!")
return nil
}