package restserver import ( "io/ioutil" "gopkg.in/yaml.v3" ) type Config struct { BindAddr string `yaml:"bind_addr"` BindPort string `yaml:"bind_port"` LogLevel string `yaml:"log_level"` } func NewConfig() *Config { return &Config{ BindAddr: ":127.0.0.1", BindPort: ":8080", LogLevel: "debug", } } 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 }