impl config State and config Interval

This commit is contained in:
Bel LaPointe
2022-01-09 21:23:27 -05:00
parent 18215b42c0
commit bf3c382877
6 changed files with 101 additions and 4 deletions

View File

@@ -1,7 +1,35 @@
package config
import "errors"
import (
"encoding/json"
"io/ioutil"
"os"
)
type Config struct {
Interval Duration
States []State
}
var live Config
func Refresh() error {
return errors.New("not impl")
configPath, ok := os.LookupEnv("CONFIG")
if !ok {
configPath = "./config.json"
}
b, err := ioutil.ReadFile(configPath)
if err != nil {
return err
}
var c Config
if err := json.Unmarshal(b, &c); err != nil {
return err
}
live = c
return nil
}
func Get() Config {
return live
}