config: fix the import issue
Showing
4 changed files
with
12 additions
and
6 deletions
| ... | @@ -14,6 +14,7 @@ import ( | ... | @@ -14,6 +14,7 @@ import ( |
| 14 | "strings" | 14 | "strings" |
| 15 | "sync" | 15 | "sync" |
| 16 | 16 | ||
| 17 | "github.com/astaxie/beego/config" | ||
| 17 | "github.com/beego/x2j" | 18 | "github.com/beego/x2j" |
| 18 | ) | 19 | ) |
| 19 | 20 | ||
| ... | @@ -24,7 +25,7 @@ type XMLConfig struct { | ... | @@ -24,7 +25,7 @@ type XMLConfig struct { |
| 24 | } | 25 | } |
| 25 | 26 | ||
| 26 | // Parse returns a ConfigContainer with parsed xml config map. | 27 | // Parse returns a ConfigContainer with parsed xml config map. |
| 27 | func (xmls *XMLConfig) Parse(filename string) (ConfigContainer, error) { | 28 | func (xmls *XMLConfig) Parse(filename string) (config.ConfigContainer, error) { |
| 28 | file, err := os.Open(filename) | 29 | file, err := os.Open(filename) |
| 29 | if err != nil { | 30 | if err != nil { |
| 30 | return nil, err | 31 | return nil, err |
| ... | @@ -101,5 +102,5 @@ func (c *XMLConfigContainer) DIY(key string) (v interface{}, err error) { | ... | @@ -101,5 +102,5 @@ func (c *XMLConfigContainer) DIY(key string) (v interface{}, err error) { |
| 101 | } | 102 | } |
| 102 | 103 | ||
| 103 | func init() { | 104 | func init() { |
| 104 | Register("xml", &XMLConfig{}) | 105 | config.Register("xml", &XMLConfig{}) |
| 105 | } | 106 | } | ... | ... |
| ... | @@ -9,6 +9,8 @@ package config | ... | @@ -9,6 +9,8 @@ package config |
| 9 | import ( | 9 | import ( |
| 10 | "os" | 10 | "os" |
| 11 | "testing" | 11 | "testing" |
| 12 | |||
| 13 | "github.com/astaxie/beego/config" | ||
| 12 | ) | 14 | ) |
| 13 | 15 | ||
| 14 | //xml parse should incluce in <config></config> tags | 16 | //xml parse should incluce in <config></config> tags |
| ... | @@ -36,7 +38,7 @@ func TestXML(t *testing.T) { | ... | @@ -36,7 +38,7 @@ func TestXML(t *testing.T) { |
| 36 | } | 38 | } |
| 37 | f.Close() | 39 | f.Close() |
| 38 | defer os.Remove("testxml.conf") | 40 | defer os.Remove("testxml.conf") |
| 39 | xmlconf, err := NewConfig("xml", "testxml.conf") | 41 | xmlconf, err := config.NewConfig("xml", "testxml.conf") |
| 40 | if err != nil { | 42 | if err != nil { |
| 41 | t.Fatal(err) | 43 | t.Fatal(err) |
| 42 | } | 44 | } | ... | ... |
| ... | @@ -16,6 +16,7 @@ import ( | ... | @@ -16,6 +16,7 @@ import ( |
| 16 | "strings" | 16 | "strings" |
| 17 | "sync" | 17 | "sync" |
| 18 | 18 | ||
| 19 | "github.com/astaxie/beego/config" | ||
| 19 | "github.com/beego/goyaml2" | 20 | "github.com/beego/goyaml2" |
| 20 | ) | 21 | ) |
| 21 | 22 | ||
| ... | @@ -24,7 +25,7 @@ type YAMLConfig struct { | ... | @@ -24,7 +25,7 @@ type YAMLConfig struct { |
| 24 | } | 25 | } |
| 25 | 26 | ||
| 26 | // Parse returns a ConfigContainer with parsed yaml config map. | 27 | // Parse returns a ConfigContainer with parsed yaml config map. |
| 27 | func (yaml *YAMLConfig) Parse(filename string) (ConfigContainer, error) { | 28 | func (yaml *YAMLConfig) Parse(filename string) (config.ConfigContainer, error) { |
| 28 | y := &YAMLConfigContainer{ | 29 | y := &YAMLConfigContainer{ |
| 29 | data: make(map[string]interface{}), | 30 | data: make(map[string]interface{}), |
| 30 | } | 31 | } |
| ... | @@ -146,5 +147,5 @@ func (c *YAMLConfigContainer) DIY(key string) (v interface{}, err error) { | ... | @@ -146,5 +147,5 @@ func (c *YAMLConfigContainer) DIY(key string) (v interface{}, err error) { |
| 146 | } | 147 | } |
| 147 | 148 | ||
| 148 | func init() { | 149 | func init() { |
| 149 | Register("yaml", &YAMLConfig{}) | 150 | config.Register("yaml", &YAMLConfig{}) |
| 150 | } | 151 | } | ... | ... |
| ... | @@ -9,6 +9,8 @@ package config | ... | @@ -9,6 +9,8 @@ package config |
| 9 | import ( | 9 | import ( |
| 10 | "os" | 10 | "os" |
| 11 | "testing" | 11 | "testing" |
| 12 | |||
| 13 | "github.com/astaxie/beego/config" | ||
| 12 | ) | 14 | ) |
| 13 | 15 | ||
| 14 | var yamlcontext = ` | 16 | var yamlcontext = ` |
| ... | @@ -33,7 +35,7 @@ func TestYaml(t *testing.T) { | ... | @@ -33,7 +35,7 @@ func TestYaml(t *testing.T) { |
| 33 | } | 35 | } |
| 34 | f.Close() | 36 | f.Close() |
| 35 | defer os.Remove("testyaml.conf") | 37 | defer os.Remove("testyaml.conf") |
| 36 | yamlconf, err := NewConfig("yaml", "testyaml.conf") | 38 | yamlconf, err := config.NewConfig("yaml", "testyaml.conf") |
| 37 | if err != nil { | 39 | if err != nil { |
| 38 | t.Fatal(err) | 40 | t.Fatal(err) |
| 39 | } | 41 | } | ... | ... |
-
Please register or sign in to post a comment