idecnode/pkg/config/config.go

36 lines
688 B
Go

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"`
}
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)
}