package config import ( "log" "gitea.urkob.com/urko/prosody-password/kit" "github.com/joho/godotenv" "github.com/kelseyhightower/envconfig" ) type Config struct { Domain string `required:"true" split_words:"true"` ApiPort string `required:"false" split_words:"true"` Views string `required:"false" split_words:"true"` } func NewConfig(envFile string) *Config { if envFile != "" { err := godotenv.Load(kit.RootDir() + "/" + envFile) if err != nil { log.Fatalln("godotenv.Load:", err) } } cfg := &Config{} err := envconfig.Process("", cfg) if err != nil { log.Fatalf("envconfig.Process: %s\n", err) } return cfg }