Skip to content

Commit

Permalink
Fixed Write bugs
Browse files Browse the repository at this point in the history
This should address a fix #93 and #94
This has not been addressed in any tests.
  • Loading branch information
orxobo authored Feb 11, 2020
1 parent b09de68 commit dbcf4b5
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions godotenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,20 @@ func Exec(filenames []string, cmd string, cmdArgs []string) error {

// Write serializes the given environment and writes it to a file
func Write(envMap map[string]string, filename string) error {
content, error := Marshal(envMap)
if error != nil {
return error
content, err := Marshal(envMap)
if err != nil {
return err
}
file, err := os.Create(filename)
if err != nil {
return err
}
file, error := os.Create(filename)
if error != nil {
return error
defer file.Close()
_, err = file.WriteString(content)
if err != nil {
return err
}
_, err := file.WriteString(content)
file.Sync()
return err
}

Expand Down

0 comments on commit dbcf4b5

Please sign in to comment.