From 37c8b8e487d129c3d0f05366a345a3604c239ed9 Mon Sep 17 00:00:00 2001 From: "John Barton (joho)" Date: Tue, 30 Jul 2013 18:38:10 +1000 Subject: [PATCH] export keyword parsing --- godotenv.go | 6 +++++- godotenv_test.go | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) 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") + }