mirror of
https://github.com/astaxie/beego.git
synced 2025-06-14 19:40:39 +00:00
fix init error of global instance
This commit is contained in:
@ -14,22 +14,10 @@
|
||||
|
||||
package config
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/core/logs"
|
||||
)
|
||||
|
||||
// We use this to simply application's development
|
||||
// for most users, they only need to use those methods
|
||||
var globalInstance Configer
|
||||
|
||||
func init() {
|
||||
// Ignore this error
|
||||
err := InitGlobalInstance("ini", "config/app.conf")
|
||||
if err != nil {
|
||||
logs.Warn("init global config instance failed. If you donot use this, just ignore it. ", err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// InitGlobalInstance will ini the global instance
|
||||
// If you want to use specific implementation, don't forget to import it.
|
||||
|
@ -29,6 +29,8 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/mitchellh/mapstructure"
|
||||
|
||||
"github.com/astaxie/beego/core/logs"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -97,7 +99,7 @@ func (ini *IniConfig) parseData(dir string, data []byte) (*IniConfigContainer, e
|
||||
break
|
||||
}
|
||||
|
||||
//It might be a good idea to throw a error on all unknonw errors?
|
||||
// It might be a good idea to throw a error on all unknonw errors?
|
||||
if _, ok := err.(*os.PathError); ok {
|
||||
return nil, err
|
||||
}
|
||||
@ -516,4 +518,11 @@ func (c *IniConfigContainer) Unmarshaler(prefix string, obj interface{}, opt ...
|
||||
|
||||
func init() {
|
||||
Register("ini", &IniConfig{})
|
||||
|
||||
err := InitGlobalInstance("ini", "config/app.conf")
|
||||
if err != nil {
|
||||
logs.Warn("init global config instance failed. If you donot use this, just ignore it. ", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Ignore this error
|
||||
|
Reference in New Issue
Block a user