proxy-detector/config/source.go

29 lines
524 B
Go

package config
import (
"os"
"gopkg.in/yaml.v3"
)
type Source struct {
Type string `json:"type" yaml:"type"`
Options CrawOption `json:"options" yaml:"options"`
}
type CrawOption struct {
Url string `json:"url" yaml:"url"`
DateFormat bool `json:"date-format" yaml:"date-format"`
}
func LoadSource(path string) ([]Source, error) {
var sources []Source
f, err := os.Open(path)
if err != nil {
return nil, err
}
defer f.Close()
err = yaml.NewDecoder(f).Decode(&sources)
return sources, err
}