diff --git a/godotenv.go b/godotenv.go index 7b215ea..dd1b4ca 100644 --- a/godotenv.go +++ b/godotenv.go @@ -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) diff --git a/godotenv_test.go b/godotenv_test.go index eaf0bf3..66ab7b4 100644 --- a/godotenv_test.go +++ b/godotenv_test.go @@ -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") + }