Skip to content

Commit

Permalink
Merge pull request #14 from jeijei4/patch-1
Browse files Browse the repository at this point in the history
Fix: Incomplete value if it contains the = symbol
  • Loading branch information
bmf-san authored Dec 30, 2022
2 parents 2c48868 + 0bbb8c8 commit 9417b80
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/infrastructure/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package infrastructure
import (
"bufio"
"os"
"regexp"
"strings"

"github.com/bmf-san/go-clean-architecture-web-application-boilerplate/app/usecases"
Expand All @@ -28,7 +29,12 @@ func Load(logger usecases.Logger) {
}

for _, l := range lines {
pair := strings.Split(l, "=")
os.Setenv(pair[0], pair[1])
pair := regexp.MustCompile(`=`).Split(l, 2)

if len(pair) > 1 {
os.Setenv(strings.TrimSpace(pair[0]), strings.TrimSpace(pair[1]))
} else {
logger.LogError(".env file. Wrong format for " + pair[0])
}
}
}

0 comments on commit 9417b80

Please sign in to comment.