Skip to content

Commit

Permalink
Merge pull request #95 from orxobo/Write-adjustment
Browse files Browse the repository at this point in the history
Fixed Write bugs
  • Loading branch information
joho authored Mar 1, 2020
2 parents b09de68 + dbcf4b5 commit d6ee687
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 d6ee687

Please sign in to comment.