Skip to content

Commit

Permalink
Fix: ioutil.ReadAll() is deprecated, so removed it's dependency (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
dreygur authored Feb 4, 2023
1 parent 4321598 commit b311b26
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions godotenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
package godotenv

import (
"bytes"
"errors"
"fmt"
"io"
"io/ioutil"
"os"
"os/exec"
"regexp"
Expand All @@ -30,12 +30,13 @@ const doubleQuoteSpecialChars = "\\\n\r\"!$`"

// Parse reads an env file from io.Reader, returning a map of keys and values.
func Parse(r io.Reader) (map[string]string, error) {
data, err := ioutil.ReadAll(r)
var buf bytes.Buffer
_, err := io.Copy(&buf, r)
if err != nil {
return nil, err
}

return UnmarshalBytes(data)
return UnmarshalBytes(buf.Bytes())
}

// Load will read your env file(s) and load them into ENV for this process.
Expand Down

0 comments on commit b311b26

Please sign in to comment.