forked from coop-cloud-mirrors/godotenv
Yaml style bro.
This commit is contained in:
parent
b10c02f9b0
commit
4a2748eb3c
10
godotenv.go
10
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], " \"'")
|
||||
|
@ -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")
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user