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

optimization code

This commit is contained in:
ysqi 2016-01-28 14:49:44 +08:00
parent 484ca3a643
commit 1222c87be3

View File

@ -119,9 +119,8 @@ func Getenv(env interface{}) (string, bool) {
// Onley support string key. // Onley support string key.
if key, ok := env.(string); ok { if key, ok := env.(string); ok {
if len(key) > len(envKeySign) && strings.HasPrefix(key, envKeySign) { if envKey := strings.TrimPrefix(key, envKeySign); envKey != key {
key = strings.TrimLeft(key, envKeySign) return os.Getenv(envKey), true
return os.Getenv(key), true
} }
} }
return "", false return "", false