MCPcopy Create free account
hub / github.com/devfeel/dotweb / parseConfigSetFile

Function parseConfigSetFile

config/configset.go:41–64  ·  view source on GitHub ↗
(configFile string, confType string)

Source from the content-addressed store, hash-verified

39}
40
41func parseConfigSetFile(configFile string, confType string) (core.ConcurrenceMap, error) {
42 content, err := ioutil.ReadFile(configFile)
43 if err != nil {
44 return nil, errors.New("DotWeb:Config:parseConfigSetFile 配置文件[" + configFile + ", " + confType + "]无法解析 - " + err.Error())
45 }
46 set := new(ConfigSet)
47 if confType == ConfigType_XML {
48 err = UnmarshalXML(content, set)
49 }
50 if confType == ConfigType_JSON {
51 err = UnmarshalJSON(content, set)
52 }
53 if confType == ConfigType_Yaml {
54 err = UnmarshalYaml(content, set)
55 }
56 if err != nil {
57 return nil, errors.New("DotWeb:Config:parseConfigSetFile config file[" + configFile + ", " + confType + "]cannot be parsed - " + err.Error())
58 }
59 item := core.NewConcurrenceMap()
60 for _, s := range set.ConfigSetNodes {
61 item.Set(s.Key, s.Value)
62 }
63 return item, nil
64}

Callers 3

ParseConfigSetXMLFunction · 0.85
ParseConfigSetJSONFunction · 0.85
ParseConfigSetYamlFunction · 0.85

Calls 6

SetMethod · 0.95
NewConcurrenceMapFunction · 0.92
UnmarshalXMLFunction · 0.85
UnmarshalJSONFunction · 0.85
UnmarshalYamlFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected