1
0
mirror of https://github.com/astaxie/beego.git synced 2024-12-23 13:30:50 +00:00

config: fix the import issue

This commit is contained in:
astaxie 2014-05-15 14:18:47 +08:00
parent af7ac98bd6
commit 10d2c7c328
4 changed files with 12 additions and 6 deletions

View File

@ -14,6 +14,7 @@ import (
"strings" "strings"
"sync" "sync"
"github.com/astaxie/beego/config"
"github.com/beego/x2j" "github.com/beego/x2j"
) )
@ -24,7 +25,7 @@ type XMLConfig struct {
} }
// Parse returns a ConfigContainer with parsed xml config map. // Parse returns a ConfigContainer with parsed xml config map.
func (xmls *XMLConfig) Parse(filename string) (ConfigContainer, error) { func (xmls *XMLConfig) Parse(filename string) (config.ConfigContainer, error) {
file, err := os.Open(filename) file, err := os.Open(filename)
if err != nil { if err != nil {
return nil, err return nil, err
@ -101,5 +102,5 @@ func (c *XMLConfigContainer) DIY(key string) (v interface{}, err error) {
} }
func init() { func init() {
Register("xml", &XMLConfig{}) config.Register("xml", &XMLConfig{})
} }

View File

@ -9,6 +9,8 @@ package config
import ( import (
"os" "os"
"testing" "testing"
"github.com/astaxie/beego/config"
) )
//xml parse should incluce in <config></config> tags //xml parse should incluce in <config></config> tags
@ -36,7 +38,7 @@ func TestXML(t *testing.T) {
} }
f.Close() f.Close()
defer os.Remove("testxml.conf") defer os.Remove("testxml.conf")
xmlconf, err := NewConfig("xml", "testxml.conf") xmlconf, err := config.NewConfig("xml", "testxml.conf")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@ -16,6 +16,7 @@ import (
"strings" "strings"
"sync" "sync"
"github.com/astaxie/beego/config"
"github.com/beego/goyaml2" "github.com/beego/goyaml2"
) )
@ -24,7 +25,7 @@ type YAMLConfig struct {
} }
// Parse returns a ConfigContainer with parsed yaml config map. // Parse returns a ConfigContainer with parsed yaml config map.
func (yaml *YAMLConfig) Parse(filename string) (ConfigContainer, error) { func (yaml *YAMLConfig) Parse(filename string) (config.ConfigContainer, error) {
y := &YAMLConfigContainer{ y := &YAMLConfigContainer{
data: make(map[string]interface{}), data: make(map[string]interface{}),
} }
@ -146,5 +147,5 @@ func (c *YAMLConfigContainer) DIY(key string) (v interface{}, err error) {
} }
func init() { func init() {
Register("yaml", &YAMLConfig{}) config.Register("yaml", &YAMLConfig{})
} }

View File

@ -9,6 +9,8 @@ package config
import ( import (
"os" "os"
"testing" "testing"
"github.com/astaxie/beego/config"
) )
var yamlcontext = ` var yamlcontext = `
@ -33,7 +35,7 @@ func TestYaml(t *testing.T) {
} }
f.Close() f.Close()
defer os.Remove("testyaml.conf") defer os.Remove("testyaml.conf")
yamlconf, err := NewConfig("yaml", "testyaml.conf") yamlconf, err := config.NewConfig("yaml", "testyaml.conf")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }