tss/app/config.go
2022-04-27 00:19:05 -04:00

35 lines
537 B
Go

package app
import (
"os"
"gopkg.in/yaml.v3"
)
type Config struct {
Feeds []struct {
Name string `yaml:"name"`
Channel string `yaml:"channel"`
Rhash string `yaml:"rhash"`
Url string `yaml:"url"`
Cron string `yaml:"cron"`
Proxy string `yaml:"proxy"`
} `yaml:"feeds"`
}
func ParseConfig(configPath string) (*Config, error) {
cfg, err := os.ReadFile(configPath)
if err != nil {
return nil, err
}
c := Config{}
err = yaml.Unmarshal(cfg, &c)
if err != nil {
return nil, err
}
return &c, nil
}