@@ -62,7 +62,7 @@ func ParseWithLookup(r io.Reader, lookupFn LookupFn) (map[string]string, error)
6262// godotenv.Load("fileone", "filetwo")
6363//
6464// It's important to note that it WILL NOT OVERRIDE an env variable that already exists - consider the .env file to set dev vars or sensible defaults
65- func Load (filenames ... string ) ( err error ) {
65+ func Load (filenames ... string ) error {
6666 return load (false , filenames ... )
6767}
6868
@@ -77,20 +77,19 @@ func Load(filenames ...string) (err error) {
7777// godotenv.Overload("fileone", "filetwo")
7878//
7979// It's important to note this WILL OVERRIDE an env variable that already exists - consider the .env file to forcefilly set all vars.
80- func Overload (filenames ... string ) ( err error ) {
80+ func Overload (filenames ... string ) error {
8181 return load (true , filenames ... )
8282}
8383
84- func load (overload bool , filenames ... string ) ( err error ) {
84+ func load (overload bool , filenames ... string ) error {
8585 filenames = filenamesOrDefault (filenames )
86-
8786 for _ , filename := range filenames {
88- err = loadFile (filename , overload )
87+ err : = loadFile (filename , overload )
8988 if err != nil {
90- return // return early on a spazout
89+ return err
9190 }
9291 }
93- return
92+ return nil
9493}
9594
9695var startsWithDigitRegex = regexp .MustCompile (`^\s*\d.*` ) // Keys starting with numbers are ignored
@@ -121,12 +120,12 @@ func ReadWithLookup(lookupFn LookupFn, filenames ...string) (map[string]string,
121120
122121// Read all env (with same file loading semantics as Load) but return values as
123122// a map rather than automatically writing values into env
124- func Read (filenames ... string ) (envMap map [string ]string , err error ) {
123+ func Read (filenames ... string ) (map [string ]string , error ) {
125124 return ReadWithLookup (nil , filenames ... )
126125}
127126
128127// Unmarshal reads an env file from a string, returning a map of keys and values.
129- func Unmarshal (str string ) (envMap map [string ]string , err error ) {
128+ func Unmarshal (str string ) (map [string ]string , error ) {
130129 return UnmarshalBytes ([]byte (str ))
131130}
132131
@@ -223,10 +222,10 @@ func loadFile(filename string, overload bool) error {
223222 return nil
224223}
225224
226- func readFile (filename string , lookupFn LookupFn ) (envMap map [string ]string , err error ) {
225+ func readFile (filename string , lookupFn LookupFn ) (map [string ]string , error ) {
227226 file , err := os .Open (filename )
228227 if err != nil {
229- return
228+ return nil , err
230229 }
231230 defer file .Close ()
232231
@@ -235,7 +234,7 @@ func readFile(filename string, lookupFn LookupFn) (envMap map[string]string, err
235234
236235var exportRegex = regexp .MustCompile (`^\s*(?:export\s+)?(.*?)\s*$` )
237236
238- func parseLine (line string , envMap map [string ]string ) (key string , value string , err error ) {
237+ func parseLine (line string , envMap map [string ]string ) (string , string , error ) {
239238 return parseLineWithLookup (line , envMap , nil )
240239}
241240func parseLineWithLookup (line string , envMap map [string ]string , lookupFn LookupFn ) (string , string , error ) {
0 commit comments