From 1222c87be38c5df4321e3d4bc56193895d44afb6 Mon Sep 17 00:00:00 2001 From: ysqi Date: Thu, 28 Jan 2016 14:49:44 +0800 Subject: [PATCH] optimization code --- config/config.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/config/config.go b/config/config.go index de2fb7f0..7dfca88a 100644 --- a/config/config.go +++ b/config/config.go @@ -119,9 +119,8 @@ func Getenv(env interface{}) (string, bool) { // Onley support string key. if key, ok := env.(string); ok { - if len(key) > len(envKeySign) && strings.HasPrefix(key, envKeySign) { - key = strings.TrimLeft(key, envKeySign) - return os.Getenv(key), true + if envKey := strings.TrimPrefix(key, envKeySign); envKey != key { + return os.Getenv(envKey), true } } return "", false