godotenv
godotenv copied to clipboard
Proper error when it can't find or parse the dotenv file
In the source code we have
// 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
func Load(filenames ...string) (err error) {
filenames = filenamesOrDefault(filenames)
for _, filename := range filenames {
err = loadFile(filename, false)
if err != nil {
return // return early on a spazout
}
}
return
}
the return // return early on a spazout behavior is questionable, in my opinion. I think it should show a normal error somehow, since it makes things easier to debug.
In my case it turned out to be an error with env file being parsed, since I had an accidental newline in one of the variables. However I couldn't figure this out without going into the dotenv source code and adding some logger statements.
Were you checking the returned err from the function? I wrote that a long time ago and it's in the now very non-idiomatic named/naked return so the error should be available.