package config import ( "os" "gopkg.in/yaml.v3" ) type Config struct { Listen string `yaml:"listen"` Node string `yaml:"node"` Store string `yaml:"store"` LoggerType int `yaml:"logger_type"` Echos map[string]Echo `yaml:"echos"` Fetch []Node `yaml:"fetch"` FilesDirectory string `yaml:"files_directory"` } type Node struct { Addr string `yaml:"addr"` Echos []string `yaml:"echos"` } type Echo struct { Description string `yaml:"description"` } func New(filePath string) (*Config, error) { cfg := new(Config) fp, err := os.Open(filePath) if err != nil { return nil, err } defer fp.Close() return cfg, yaml.NewDecoder(fp).Decode(cfg) }