| Conditions | 5 |
| Total Lines | 20 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | package configuration |
||
| 11 | func Load(conf Config, filename string) Config { |
||
| 12 | var err error |
||
| 13 | |||
| 14 | if util.FileExists(filename) { |
||
| 15 | data, err := ioutil.ReadFile(filename) |
||
| 16 | if err == nil { |
||
| 17 | loadedConf, err := conf.Schema().Parse(data) |
||
| 18 | if err == nil { |
||
| 19 | return loadedConf.MergeDefault(conf) |
||
| 20 | } |
||
| 21 | } |
||
| 22 | } else { |
||
| 23 | log.Failure("Config load failed, file not exists", getType(conf)) |
||
| 24 | } |
||
| 25 | |||
| 26 | if err != nil { |
||
| 27 | log.Failure(fmt.Sprintf("Config \"%s\" read", filename), err.Error()) |
||
| 28 | } |
||
| 29 | |||
| 30 | return conf |
||
| 31 | } |
||
| 40 |