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

Function JsonConfigHandler

config.go:63–82  ·  view source on GitHub ↗

初始化配置文件(json)

(configFile string)

Source from the content-addressed store, hash-verified

61
62//初始化配置文件(json)
63func 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)
85func YamlConfigHandler(configFile string) *AppConfig {

Callers 1

LoadFileConfigMethod · 0.85

Calls 2

lookupFileFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected