func init() { //读取配置文件信息 settings := func(path string) map[string]string { return goutils.NewConfig().Load(path).GlobalContent() }("conf/app.conf") //获取settings中的信息 dbinfo, ok := settings["DBINFO"] if !ok { log.Fatal("not found DBINFO in config file") } orm.RegisterDriver("mysql", orm.DRMySQL) orm.RegisterDataBase("default", "mysql", dbinfo) orm.RegisterModel( new(First), new(Second), new(System), new(Userinfo), new(Userlog), new(Novel), new(Content), new(Collectrank), new(Clickrank), new(Recommend), ) }
// Conf gets singleton instance of Config. func Conf() *goutils.Config { if conf == nil { if path == "" { path = configpath() } conf = goutils.NewConfig().Load(path) } return conf }
func LoadConf(path string) (settings map[string]string) { //生成配置文件对象,加载配置文件 config := goutils.NewConfig().Load(path) return config.GlobalContent() }