Use SplitN instead of split

pull/3/head
Yannick Schutz 2014-03-07 23:21:31 +01:00
parent 6e333bd708
commit 7e3e1e2c6c
3 changed files with 12 additions and 1 deletions

2
fixtures/equals.env Normal file
View File

@ -0,0 +1,2 @@
export OPTION_A='postgres://localhost:5432/database?sslmode=disable'

View File

@ -138,7 +138,7 @@ func parseLine(line string) (key string, value string, err error) {
}
// now split key from value
splitString := strings.Split(line, "=")
splitString := strings.SplitN(line, "=", 2)
if len(splitString) != 2 {
// try yaml mode!

View File

@ -93,6 +93,15 @@ func TestLoadExportedEnv(t *testing.T) {
loadEnvAndCompareValues(t, envFileName, expectedValues)
}
func TestLoadEqualsEnv(t *testing.T) {
envFileName := "fixtures/equals.env"
expectedValues := map[string]string{
"OPTION_A": "postgres://localhost:5432/database?sslmode=disable",
}
loadEnvAndCompareValues(t, envFileName, expectedValues)
}
func TestLoadQuotedEnv(t *testing.T) {
envFileName := "fixtures/quoted.env"
expectedValues := map[string]string{