mirror of https://github.com/joho/godotenv.git
parent
4321598b05
commit
b311b2657d
|
@ -14,10 +14,10 @@
|
||||||
package godotenv
|
package godotenv
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
@ -30,12 +30,13 @@ const doubleQuoteSpecialChars = "\\\n\r\"!$`"
|
||||||
|
|
||||||
// Parse reads an env file from io.Reader, returning a map of keys and values.
|
// Parse reads an env file from io.Reader, returning a map of keys and values.
|
||||||
func Parse(r io.Reader) (map[string]string, error) {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
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.
|
// Load will read your env file(s) and load them into ENV for this process.
|
||||||
|
|
Loading…
Reference in New Issue