You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"io/ioutil"
|
|
|
|
)
|
|
|
|
|
|
|
|
func loadConfig() Config {
|
|
|
|
var c Config
|
|
|
|
confFile, _ := ioutil.ReadFile(configFile)
|
|
|
|
_ = json.Unmarshal([]byte(confFile), &c)
|
|
|
|
return c
|
|
|
|
}
|
|
|
|
|
|
|
|
func saveConfig() {
|
|
|
|
defer log.PanicSafe("saveConfig")
|
|
|
|
log.LogInfo("Saving config.")
|
|
|
|
file, err := json.Marshal(config)
|
|
|
|
if err != nil {
|
|
|
|
log.LogErrorType(err)
|
|
|
|
}
|
|
|
|
err = ioutil.WriteFile(configFile, file, 0600)
|
|
|
|
if err != nil {
|
|
|
|
log.LogErrorType(err)
|
|
|
|
}
|
|
|
|
log.LogInfo("Config Saved.")
|
|
|
|
}
|