1
0
mirror of https://github.com/beego/bee.git synced 2024-11-22 05:00:54 +00:00

Merge pull request #369 from sergeylanzman/merge-default-config-with-config-file

merge default config with config file
This commit is contained in:
astaxie 2017-03-11 12:24:45 +08:00 committed by GitHub
commit 78836f0a4c

View File

@ -88,7 +88,12 @@ func init() {
} }
// loadConfig loads customized configuration. // loadConfig loads customized configuration.
func loadConfig() (err error) { func loadConfig() {
beeLogger.Log.Info("Loading default configuration...")
err := json.Unmarshal([]byte(defaultConf), &Conf)
if err != nil {
beeLogger.Log.Errorf(err.Error())
}
err = filepath.Walk(".", func(path string, fileInfo os.FileInfo, err error) error { err = filepath.Walk(".", func(path string, fileInfo os.FileInfo, err error) error {
if err != nil { if err != nil {
return nil return nil
@ -119,20 +124,6 @@ func loadConfig() (err error) {
} }
return nil return nil
}) })
// In case no configuration file found or an error different than io.EOF,
// fallback to default configuration
if err != io.EOF {
beeLogger.Log.Info("Loading default configuration...")
err = json.Unmarshal([]byte(defaultConf), &Conf)
if err != nil {
return
}
}
// No need to return io.EOF error
err = nil
// Check format version // Check format version
if Conf.Version != confVer { if Conf.Version != confVer {
beeLogger.Log.Warn("Your configuration file is outdated. Please do consider updating it.") beeLogger.Log.Warn("Your configuration file is outdated. Please do consider updating it.")