From b311b2657d7c3f549674adf6080d032437caa68c Mon Sep 17 00:00:00 2001 From: Rakibul Yeasin Date: Sat, 4 Feb 2023 06:10:05 +0600 Subject: [PATCH] Fix: ioutil.ReadAll() is deprecated, so removed it's dependency (#202) --- godotenv.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/godotenv.go b/godotenv.go index 7762b5b..3d312f3 100644 --- a/godotenv.go +++ b/godotenv.go @@ -14,10 +14,10 @@ package godotenv import ( + "bytes" "errors" "fmt" "io" - "io/ioutil" "os" "os/exec" "regexp" @@ -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.