初始化配置文件(json)
(configFile string)
| 61 | |
| 62 | //初始化配置文件(json) |
| 63 | func JsonConfigHandler(configFile string) *AppConfig { |
| 64 | realFile, exists := lookupFile(configFile) |
| 65 | if !exists { |
| 66 | panic("Task:Config:InitConfig 配置文件[" + configFile + "]无法解析 - 无法寻找到指定配置文件") |
| 67 | os.Exit(1) |
| 68 | } |
| 69 | content, err := ioutil.ReadFile(realFile) |
| 70 | if err != nil { |
| 71 | panic("Task:Config:InitJsonConfig 配置文件[" + realFile + "]无法解析 - " + err.Error()) |
| 72 | os.Exit(1) |
| 73 | } |
| 74 | |
| 75 | var config AppConfig |
| 76 | err = json.Unmarshal(content, &config) |
| 77 | if err != nil { |
| 78 | panic("Task:Config:InitJsonConfig 配置文件[" + realFile + "]解析失败 - " + err.Error()) |
| 79 | os.Exit(1) |
| 80 | } |
| 81 | return &config |
| 82 | } |
| 83 | |
| 84 | //初始化配置文件(yaml) |
| 85 | func YamlConfigHandler(configFile string) *AppConfig { |
no test coverage detected