You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
640 B

2 years ago
package config
import (
"log"
"github.com/kelseyhightower/envconfig"
)
2 years ago
type smtpConfig struct {
Port int `envconfig:"SMTP_PORT"`
Host string `envconfig:"SMTP_HOST"`
Sender string `envconfig:"SMTP_SENDER"`
Password string `envconfig:"SMTP_PASSWORD"`
}
2 years ago
type kafkaConfig struct {
2 years ago
Port int `envconfig:"KAFKA_PORT"`
Partition int `envconfig:"KAFKA_PARTITION"`
Host string `envconfig:"KAFKA_HOST"`
2 years ago
}
// ...
type Config struct {
2 years ago
Smtp smtpConfig
2 years ago
Kafka kafkaConfig
}
func NewConfig() *Config {
c := Config{}
err := envconfig.Process("", &c)
if err != nil {
log.Fatal(err.Error())
}
return &c
}