diff --git a/pkg/config/ini/ini.go b/pkg/config/ini.go similarity index 97% rename from pkg/config/ini/ini.go rename to pkg/config/ini.go index 17408d85..f5921308 100644 --- a/pkg/config/ini/ini.go +++ b/pkg/config/ini.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package ini +package config import ( "bufio" @@ -26,8 +26,6 @@ import ( "strconv" "strings" "sync" - - "github.com/astaxie/beego/pkg/config" ) var ( @@ -47,7 +45,7 @@ type IniConfig struct { } // Parse creates a new Config and parses the file configuration from the named file. -func (ini *IniConfig) Parse(name string) (config.Configer, error) { +func (ini *IniConfig) Parse(name string) (Configer, error) { return ini.parseFile(name) } @@ -197,7 +195,7 @@ func (ini *IniConfig) parseData(dir string, data []byte) (*IniConfigContainer, e val = bytes.Trim(val, `"`) } - cfg.data[section][key] = config.ExpandValueEnv(string(val)) + cfg.data[section][key] = ExpandValueEnv(string(val)) if comment.Len() > 0 { cfg.keyComment[section+"."+key] = comment.String() comment.Reset() @@ -210,7 +208,7 @@ func (ini *IniConfig) parseData(dir string, data []byte) (*IniConfigContainer, e // ParseData parse ini the data // When include other.conf,other.conf is either absolute directory // or under beego in default temporary directory(/tmp/beego[-username]). -func (ini *IniConfig) ParseData(data []byte) (config.Configer, error) { +func (ini *IniConfig) ParseData(data []byte) (Configer, error) { dir := "beego" currentUser, err := user.Current() if err == nil { @@ -235,7 +233,7 @@ type IniConfigContainer struct { // Bool returns the boolean value for a given key. func (c *IniConfigContainer) Bool(key string) (bool, error) { - return config.ParseBool(c.getdata(key)) + return ParseBool(c.getdata(key)) } // DefaultBool returns the boolean value for a given key. @@ -502,5 +500,5 @@ func (c *IniConfigContainer) getdata(key string) string { } func init() { - config.Register("ini", &IniConfig{}) + Register("ini", &IniConfig{}) } diff --git a/pkg/config/ini/ini_test.go b/pkg/config/ini_test.go similarity index 95% rename from pkg/config/ini/ini_test.go rename to pkg/config/ini_test.go index 70f1091d..ffcdb294 100644 --- a/pkg/config/ini/ini_test.go +++ b/pkg/config/ini_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package ini +package config import ( "fmt" @@ -20,8 +20,6 @@ import ( "os" "strings" "testing" - - "github.com/astaxie/beego/pkg/config" ) func TestIni(t *testing.T) { @@ -94,7 +92,7 @@ password = ${GOPATH} } f.Close() defer os.Remove("testini.conf") - iniconf, err := config.NewConfig("ini", "testini.conf") + iniconf, err := NewConfig("ini", "testini.conf") if err != nil { t.Fatal(err) } @@ -167,7 +165,7 @@ httpport=8080 name=mysql ` ) - cfg, err := config.NewConfigData("ini", []byte(inicontext)) + cfg, err := NewConfigData("ini", []byte(inicontext)) if err != nil { t.Fatal(err) }