MCPcopy Create free account
hub / github.com/devfeel/dottask / XmlConfigHandler

Function XmlConfigHandler

config.go:40–60  ·  view source on GitHub ↗

初始化配置文件(xml)

(configFile string)

Source from the content-addressed store, hash-verified

38
39//初始化配置文件(xml)
40func 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)
63func JsonConfigHandler(configFile string) *AppConfig {

Callers 1

LoadFileConfigMethod · 0.85

Calls 2

lookupFileFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected