2024-08-13 00:01:00 +00:00
|
|
|
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"`
|
2024-08-13 00:01:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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{}
|
|
|
|
|
2024-08-13 00:01:00 +00:00
|
|
|
if err = json.Unmarshal(content, c); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|