package pancheri import ( "github.com/sirupsen/logrus" "gopkg.in/yaml.v2" "os" ) type Config struct { Server struct { Host string `yaml:"host"` Port string `yaml:"port"` } `yaml:"server"` Resolver struct { Enable bool `yaml:"enable"` Upstream string `yaml:"upstream"` } Logging struct { Format string `yaml:"format"` Level logrus.Level `yaml:"level"` } Zone struct { LoadFiles []string `yaml:"load_files"` } `yaml:"zone"` Blackhole struct { Enable bool `yaml:"enable"` BlockLists []string `yaml:"block_lists"` } } func LoadConfig(path string) (*Config, error) { f, err := os.Open(path) if err != nil { return nil, err } var cfg Config decoder := yaml.NewDecoder(f) err = decoder.Decode(&cfg) if err != nil { return nil, err } err = f.Close() if err != nil { return nil, err } return &cfg, nil }