50 lines
844 B
Go
50 lines
844 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
"gopkg.in/yaml.v2"
|
|
)
|
|
|
|
var Cfg Config
|
|
|
|
type Config struct {
|
|
Debug bool
|
|
DefaultLanguageCode string `yaml:"defaultLanguageCode"`
|
|
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 `yaml:"folderPath"`
|
|
ConfigPath string `yaml:"configPath"`
|
|
}
|
|
|
|
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)
|
|
}
|
|
}
|