初始化配置文件(xml)
(configFile string)
| 38 | |
| 39 | //初始化配置文件(xml) |
| 40 | func XmlConfigHandler(configFile string) *AppConfig { |
| 41 | realFile, exists := lookupFile(configFile) |
| 42 | if !exists { |
| 43 | panic("Task:Config:InitConfig 配置文件[" + configFile + "]无法解析 - 无法寻找到指定配置文件") |
| 44 | os.Exit(1) |
| 45 | } |
| 46 | |
| 47 | content, err := ioutil.ReadFile(realFile) |
| 48 | if err != nil { |
| 49 | panic("Task:Config:InitConfig 配置文件[" + realFile + "]无法解析 - " + err.Error()) |
| 50 | os.Exit(1) |
| 51 | } |
| 52 | |
| 53 | var config AppConfig |
| 54 | err = xml.Unmarshal(content, &config) |
| 55 | if err != nil { |
| 56 | panic("Task:Config:InitConfig 配置文件[" + realFile + "]解析失败 - " + err.Error()) |
| 57 | os.Exit(1) |
| 58 | } |
| 59 | return &config |
| 60 | } |
| 61 | |
| 62 | //初始化配置文件(json) |
| 63 | func JsonConfigHandler(configFile string) *AppConfig { |
no test coverage detected