1
0
mirror of https://github.com/beego/bee.git synced 2024-11-25 04:40:54 +00:00
Passes the conf variable by reference to JSON and YAML parsers instead of
a copy.
This commit is contained in:
Faissal Elamraoui 2016-12-25 13:24:11 +01:00
parent d801cc2469
commit e215969963

View File

@ -90,7 +90,7 @@ func loadConfig() (err error) {
if fileInfo.Name() == "bee.json" { if fileInfo.Name() == "bee.json" {
logger.Info("Loading configuration from 'bee.json'...") logger.Info("Loading configuration from 'bee.json'...")
err = parseJSON(path, conf) err = parseJSON(path, &conf)
if err != nil { if err != nil {
logger.Errorf("Failed to parse JSON file: %s", err) logger.Errorf("Failed to parse JSON file: %s", err)
return err return err
@ -100,7 +100,7 @@ func loadConfig() (err error) {
if fileInfo.Name() == "Beefile" { if fileInfo.Name() == "Beefile" {
logger.Info("Loading configuration from 'Beefile'...") logger.Info("Loading configuration from 'Beefile'...")
err = parseYAML(path, conf) err = parseYAML(path, &conf)
if err != nil { if err != nil {
logger.Errorf("Failed to parse YAML file: %s", err) logger.Errorf("Failed to parse YAML file: %s", err)
return err return err
@ -151,7 +151,7 @@ func parseJSON(path string, v interface{}) error {
if err != nil { if err != nil {
return err return err
} }
err = json.Unmarshal(data, &v) err = json.Unmarshal(data, v)
if err != nil { if err != nil {
return err return err
} }
@ -167,7 +167,7 @@ func parseYAML(path string, v interface{}) error {
if err != nil { if err != nil {
return err return err
} }
err = yaml.Unmarshal(data, &v) err = yaml.Unmarshal(data, v)
if err != nil { if err != nil {
return err return err
} }