package lib import ( "encoding/json" "os" ) type Config struct { 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 } // default config values c.Interval = 5 c.Pools = []Pool{} if err = json.Unmarshal(content, c); err != nil { return err } return nil }