49 lines
1.6 KiB
Go
49 lines
1.6 KiB
Go
package cfg
|
|
|
|
import (
|
|
"log"
|
|
|
|
"github.com/joho/godotenv"
|
|
"github.com/kelseyhightower/envconfig"
|
|
)
|
|
|
|
type Config struct {
|
|
LogFile bool `required:"false" split_words:"true"`
|
|
Host string `required:"true" split_words:"true"`
|
|
DbAddress string `required:"true" split_words:"true"`
|
|
DbName string `required:"true" split_words:"true"`
|
|
OrdersCollection string `required:"true" split_words:"true"`
|
|
RpcZmq string `required:"true" split_words:"true"`
|
|
RpcAuth string `required:"true" split_words:"true"`
|
|
RpcHost string `required:"true" split_words:"true"`
|
|
WalletAddress string `required:"true" split_words:"true"`
|
|
ApiPort string `required:"true" split_words:"true"`
|
|
Views string `required:"true" split_words:"true"`
|
|
ConversorApi string `required:"true" split_words:"true"`
|
|
DollarRateApi string `required:"true" split_words:"true"`
|
|
MailHost string `required:"true" split_words:"true"`
|
|
MailPort string `required:"true" split_words:"true"`
|
|
MailUser string `required:"true" split_words:"true"`
|
|
MailPassword string `required:"true" split_words:"true"`
|
|
MailFrom string `required:"true" split_words:"true"`
|
|
MailTemplatesDir string `required:"true" split_words:"true"`
|
|
MailTo string `required:"false" split_words:"true"`
|
|
}
|
|
|
|
func NewConfig(envFile string) *Config {
|
|
if envFile != "" {
|
|
err := godotenv.Load(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
|
|
}
|