46 lines
799 B
Go
46 lines
799 B
Go
package config
|
|
|
|
import (
|
|
"gopkg.in/yaml.v2"
|
|
"os"
|
|
)
|
|
|
|
type Config struct {
|
|
Db Database `yaml:"db"`
|
|
Storage Storage `yaml:"storage"`
|
|
PaymentService PaymentService `yaml:"paymentService"`
|
|
}
|
|
|
|
type Database struct {
|
|
Username string `yaml:"username"`
|
|
Password string `yaml:"password"`
|
|
Host string `yaml:"host"`
|
|
Port string `yaml:"port"`
|
|
DBName string `yaml:"dbname"`
|
|
}
|
|
|
|
type Storage struct {
|
|
Filer string `yaml:"filer"`
|
|
Master string `yaml:"master"`
|
|
}
|
|
|
|
type PaymentService struct {
|
|
Host string `yaml:"host"`
|
|
Port string `yaml:"port"`
|
|
}
|
|
|
|
func Init() *Config {
|
|
data, err := os.ReadFile("internal/config/config.yaml")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
var cfg Config
|
|
|
|
err = yaml.Unmarshal(data, &cfg)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return &cfg
|
|
}
|