mirror of
https://github.com/joho/godotenv.git
synced 2025-07-08 17:54:04 +00:00
export keyword parsing
This commit is contained in:
@ -70,7 +70,11 @@ func parseLine(line string) (key string, value string, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
key = strings.Trim(splitString[0], " ")
|
||||
key = splitString[0]
|
||||
if strings.HasPrefix(key, "export") {
|
||||
key = strings.TrimPrefix(key, "export")
|
||||
}
|
||||
key = strings.Trim(key, " ")
|
||||
|
||||
value = strings.Trim(splitString[1], " \"'")
|
||||
value = strings.Replace(value, "\\\"", "\"", -1)
|
||||
|
@ -67,4 +67,7 @@ func TestParsing(t *testing.T) {
|
||||
// parses yaml style options
|
||||
parseAndCompare(t, "OPTION_A: 1", "OPTION_A", "1")
|
||||
|
||||
// parses export keyword
|
||||
parseAndCompare(t, "export OPTION_A=2", "OPTION_A", "2")
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user