From a6ced64441303fb35ad24728f997026469481e27 Mon Sep 17 00:00:00 2001 From: fuxiaohei Date: Thu, 17 Jul 2014 16:22:41 +0800 Subject: [PATCH] code style simplify --- config/xml/xml.go | 14 +++++++------- config/xml/xml_test.go | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/config/xml/xml.go b/config/xml/xml.go index fbd15190..5345f69c 100644 --- a/config/xml/xml.go +++ b/config/xml/xml.go @@ -7,7 +7,7 @@ // @license http://github.com/astaxie/beego/blob/master/LICENSE // // @authors astaxie -package config +package xml import ( "errors" @@ -24,27 +24,27 @@ import ( // XmlConfig is a xml config parser and implements Config interface. // xml configurations should be included in tag. // only support key/value pair as value as each item. -type XMLConfig struct { -} +type XMLConfig struct{} // Parse returns a ConfigContainer with parsed xml config map. -func (xmls *XMLConfig) Parse(filename string) (config.ConfigContainer, error) { +func (xc *XMLConfig) Parse(filename string) (config.ConfigContainer, error) { file, err := os.Open(filename) if err != nil { return nil, err } defer file.Close() - x := &XMLConfigContainer{ - data: make(map[string]interface{}), - } + + x := &XMLConfigContainer{data: make(map[string]interface{})} content, err := ioutil.ReadAll(file) if err != nil { return nil, err } + d, err := x2j.DocToMap(string(content)) if err != nil { return nil, err } + x.data = d["config"].(map[string]interface{}) return x, nil } diff --git a/config/xml/xml_test.go b/config/xml/xml_test.go index dac1a527..564d6344 100644 --- a/config/xml/xml_test.go +++ b/config/xml/xml_test.go @@ -7,7 +7,7 @@ // @license http://github.com/astaxie/beego/blob/master/LICENSE // // @authors astaxie -package config +package xml import ( "os"