diff --git a/godotenv.go b/godotenv.go index e58a80f..7b215ea 100644 --- a/godotenv.go +++ b/godotenv.go @@ -60,6 +60,16 @@ func parseLine(line string) (key string, value string, err error) { splitString := strings.Split(line, "=") + if len(splitString) != 2 { + // try yaml mode! + splitString = strings.Split(line, ":") + } + + if len(splitString) != 2 { + err = errors.New("Can't separate key from value") + return + } + key = strings.Trim(splitString[0], " ") value = strings.Trim(splitString[1], " \"'") diff --git a/godotenv_test.go b/godotenv_test.go index 44ffe58..eaf0bf3 100644 --- a/godotenv_test.go +++ b/godotenv_test.go @@ -63,4 +63,8 @@ func TestParsing(t *testing.T) { // parses escaped double quotes parseAndCompare(t, "FOO=escaped\\\"bar\"", "FOO", "escaped\"bar") + + // parses yaml style options + parseAndCompare(t, "OPTION_A: 1", "OPTION_A", "1") + }