if dotenv file does not exist, do not load it

This commit is contained in:
c9s 2021-02-04 20:33:03 +08:00
parent 39fa0ef810
commit bd895149ad

View File

@ -320,8 +320,10 @@ func run(cmd *cobra.Command, args []string) error {
return err
}
if err := godotenv.Load(dotenvFile); err != nil {
return errors.Wrap(err, "error loading dotenv file")
if _, err := os.Stat(dotenvFile) ; err == nil {
if err := godotenv.Load(dotenvFile); err != nil {
return errors.Wrap(err, "error loading dotenv file")
}
}
}