feat: do not fail when .env is missing (#10)

This commit is contained in:
Patryk M
2024-05-27 04:08:32 +02:00
committed by GitHub
parent a1eaa63886
commit 7a632190a0

View File

@@ -1,6 +1,7 @@
package memogram
import (
"os"
"github.com/caarlos0/env"
"github.com/joho/godotenv"
"github.com/pkg/errors"
@@ -12,10 +13,13 @@ type Config struct {
}
func getConfigFromEnv() (*Config, error) {
err := godotenv.Load(".env")
envFileName := ".env"
if _, err := os.Stat(envFileName); err == nil {
err := godotenv.Load(envFileName)
if err != nil {
panic(err.Error())
}
}
config := Config{}
if err := env.Parse(&config); err != nil {