idecnode/pkg/config/config.go
2024-10-20 20:38:08 +03:00

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