allow empty_var

This commit is contained in:
Oenning 2017-03-22 13:05:44 +00:00
parent b01826f956
commit a42a65518c
3 changed files with 16 additions and 9 deletions

View File

@ -3,3 +3,5 @@ OPTION_B=2
OPTION_C= 3
OPTION_D =4
OPTION_E = 5
OPTION_F =
OPTION_G=

View File

@ -212,10 +212,12 @@ func parseLine(line string) (key string, value string, err error) {
// Parse the value
value = splitString[1]
// trim
value = strings.Trim(value, " ")
// check if we've got quoted values
if value != "" {
first := string(value[0:1])
last := string(value[len(value)-1:])
if first == last && strings.ContainsAny(first, `"'`) {
@ -227,6 +229,7 @@ func parseLine(line string) (key string, value string, err error) {
// expand newlines
value = strings.Replace(value, `\n`, "\n", -1)
}
}
return
}

View File

@ -74,6 +74,8 @@ func TestReadPlainEnv(t *testing.T) {
"OPTION_C": "3",
"OPTION_D": "4",
"OPTION_E": "5",
"OPTION_F": "",
"OPTION_G": "",
}
envMap, err := Read(envFileName)