49 lines
707 B
Go
49 lines
707 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
"gopkg.in/yaml.v2"
|
|
)
|
|
|
|
var Cfg Config
|
|
|
|
type Config struct {
|
|
Debug bool
|
|
RabbitMq RabbitMq
|
|
Mail Mail
|
|
Templates Templates
|
|
}
|
|
|
|
type RabbitMq struct {
|
|
Host string
|
|
Username string
|
|
Password string
|
|
}
|
|
|
|
type Mail struct {
|
|
Host string
|
|
Username string
|
|
Password string
|
|
Port string
|
|
From string
|
|
}
|
|
|
|
type Templates struct {
|
|
FolderPath string
|
|
ConfigPath string
|
|
}
|
|
|
|
func LoadConfig() {
|
|
data, err := os.ReadFile("config.yml")
|
|
|
|
if err != nil {
|
|
logrus.Fatalln("Failed to read config file, err:", err)
|
|
}
|
|
|
|
if err := yaml.Unmarshal(data, &Cfg); err != nil {
|
|
logrus.Fatalln("Failed to unmarshal config file, err:", err)
|
|
}
|
|
}
|