tracker/lib/config.go

33 lines
456 B
Go
Raw Permalink Normal View History

package lib
import (
"encoding/json"
"os"
)
type Config struct {
2024-11-22 13:56:02 +00:00
Interval int `json:"interval"`
Pools []Pool `json:"pools"`
}
func (c *Config) Load(list *[]Package, file string) error {
var (
content []byte
err error
)
if content, err = os.ReadFile(file); err != nil {
return err
}
2024-11-22 13:56:02 +00:00
// default config values
c.Interval = 5
c.Pools = []Pool{}
if err = json.Unmarshal(content, c); err != nil {
return err
}
return nil
}