35 lines
534 B
Go
35 lines
534 B
Go
|
package config
|
||
|
|
||
|
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 Parse(configPath string) (*Config, error) {
|
||
|
cfg, err := os.ReadFile("tss.yaml")
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
c := Config{}
|
||
|
err = yaml.Unmarshal(cfg, &c)
|
||
|
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
return &c, nil
|
||
|
}
|