Other: pretty print prefs.json

This commit is contained in:
James Houlahan
2021-02-15 11:12:36 +01:00
parent e6ae344f1f
commit fb89fb7b31
2 changed files with 7 additions and 7 deletions

View File

@ -21,6 +21,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"strconv"
"sync"
@ -73,13 +74,12 @@ func (p *keyValueStore) save() error {
p.lock.Lock()
defer p.lock.Unlock()
f, err := os.Create(p.path)
b, err := json.MarshalIndent(p.cache, "", "\t")
if err != nil {
return err
}
defer f.Close() //nolint[errcheck]
return json.NewEncoder(f).Encode(p.cache)
return ioutil.WriteFile(p.path, b, 0600)
}
func (p *keyValueStore) setDefault(key, value string) {