mirror of
https://github.com/astaxie/beego.git
synced 2025-06-12 22:20:38 +00:00
Merge branch 'astaxie/develop' into environmentVar
# Conflicts: # config/fake.go # config/xml/xml_test.go # config/yaml/yaml_test.go
This commit is contained in:
@ -227,14 +227,18 @@ func (c *ConfigContainer) DefaultString(key string, defaultval string) string {
|
||||
|
||||
// Strings returns the []string value for a given key.
|
||||
func (c *ConfigContainer) Strings(key string) []string {
|
||||
return strings.Split(c.String(key), ";")
|
||||
v := c.String(key)
|
||||
if v == "" {
|
||||
return nil
|
||||
}
|
||||
return strings.Split(v, ";")
|
||||
}
|
||||
|
||||
// DefaultStrings returns the []string value for a given key.
|
||||
// if err != nil return defaltval
|
||||
func (c *ConfigContainer) DefaultStrings(key string, defaultval []string) []string {
|
||||
v := c.Strings(key)
|
||||
if len(v) == 0 {
|
||||
if v == nil {
|
||||
return defaultval
|
||||
}
|
||||
return v
|
||||
|
@ -105,4 +105,8 @@ func TestYaml(t *testing.T) {
|
||||
} else if strings.Contains(dbinfo["detail"], os.Getenv("GOROOT")) == false {
|
||||
t.Fatal("get GOROOT path error")
|
||||
}
|
||||
|
||||
if yamlconf.Strings("emptystrings") != nil {
|
||||
t.Fatal("get emtpy strings error")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user