Support empty default environment value
This commit is contained in:
+5
-3
@@ -12,17 +12,19 @@ func ReplaceEnvVars(text string) string {
|
|||||||
key := match[2 : len(match)-1]
|
key := match[2 : len(match)-1]
|
||||||
|
|
||||||
var def string
|
var def string
|
||||||
|
var dok bool
|
||||||
|
|
||||||
i := strings.IndexByte(key, ':')
|
i := strings.IndexByte(key, ':')
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
key, def = key[:i], key[i+1:]
|
key, def = key[:i], key[i+1:]
|
||||||
|
dok = true
|
||||||
}
|
}
|
||||||
|
|
||||||
value, exists := os.LookupEnv(key)
|
if value, vok := os.LookupEnv(key); vok {
|
||||||
if exists {
|
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
if def != "" {
|
if dok {
|
||||||
return def
|
return def
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user