package restserver import ( "io/ioutil" "git.ukamnya.ru/stulyaganov/RestApiv2/internal/bd" "gopkg.in/yaml.v3" ) type Config struct { BindAddr string `yaml:"bind_addr"` BindPort string `yaml:"bind_port"` LogLevel string `yaml:"log_level"` DB *bd.ConfigBD `yaml:"DB"` } func NewConfig() *Config { return &Config{ BindAddr: ":127.0.0.1", BindPort: ":8080", LogLevel: "debug", DB: bd.NewConfig(), } } func (c *Config) SetConfig(path string) error { yamlPars, err := ioutil.ReadFile(path) if err != nil { return err } err = yaml.Unmarshal(yamlPars, c) if err != nil { return err } return nil }