if dotenv file does not exist, do not load it

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

View File

@ -19,10 +19,14 @@ import (
func main() { func main() {
dotenvFile := ".env.local" dotenvFile := ".env.local"
if _, err := os.Stat(dotenvFile) ; err == nil {
if err := godotenv.Load(dotenvFile); err != nil { if err := godotenv.Load(dotenvFile); err != nil {
log.WithError(err).Error("error loading dotenv file") log.WithError(err).Error("error loading dotenv file")
return return
} }
}
var args []string var args []string
if runtime.GOOS == "linux" { if runtime.GOOS == "linux" {