a6ced644 by fuxiaohei

code style simplify

1 parent 84da1c92
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
7 // @license http://github.com/astaxie/beego/blob/master/LICENSE 7 // @license http://github.com/astaxie/beego/blob/master/LICENSE
8 // 8 //
9 // @authors astaxie 9 // @authors astaxie
10 package config 10 package xml
11 11
12 import ( 12 import (
13 "errors" 13 "errors"
...@@ -24,27 +24,27 @@ import ( ...@@ -24,27 +24,27 @@ import (
24 // XmlConfig is a xml config parser and implements Config interface. 24 // XmlConfig is a xml config parser and implements Config interface.
25 // xml configurations should be included in <config></config> tag. 25 // xml configurations should be included in <config></config> tag.
26 // only support key/value pair as <key>value</key> as each item. 26 // only support key/value pair as <key>value</key> as each item.
27 type XMLConfig struct { 27 type XMLConfig struct{}
28 }
29 28
30 // Parse returns a ConfigContainer with parsed xml config map. 29 // Parse returns a ConfigContainer with parsed xml config map.
31 func (xmls *XMLConfig) Parse(filename string) (config.ConfigContainer, error) { 30 func (xc *XMLConfig) Parse(filename string) (config.ConfigContainer, error) {
32 file, err := os.Open(filename) 31 file, err := os.Open(filename)
33 if err != nil { 32 if err != nil {
34 return nil, err 33 return nil, err
35 } 34 }
36 defer file.Close() 35 defer file.Close()
37 x := &XMLConfigContainer{ 36
38 data: make(map[string]interface{}), 37 x := &XMLConfigContainer{data: make(map[string]interface{})}
39 }
40 content, err := ioutil.ReadAll(file) 38 content, err := ioutil.ReadAll(file)
41 if err != nil { 39 if err != nil {
42 return nil, err 40 return nil, err
43 } 41 }
42
44 d, err := x2j.DocToMap(string(content)) 43 d, err := x2j.DocToMap(string(content))
45 if err != nil { 44 if err != nil {
46 return nil, err 45 return nil, err
47 } 46 }
47
48 x.data = d["config"].(map[string]interface{}) 48 x.data = d["config"].(map[string]interface{})
49 return x, nil 49 return x, nil
50 } 50 }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
7 // @license http://github.com/astaxie/beego/blob/master/LICENSE 7 // @license http://github.com/astaxie/beego/blob/master/LICENSE
8 // 8 //
9 // @authors astaxie 9 // @authors astaxie
10 package config 10 package xml
11 11
12 import ( 12 import (
13 "os" 13 "os"
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!