use hujson for config file

This commit is contained in:
shoopea
2023-06-30 22:04:22 +02:00
parent aa8d20370b
commit c372d43104
4 changed files with 15 additions and 5 deletions

View File

@@ -10,6 +10,7 @@ import (
"time"
log "github.com/sirupsen/logrus"
"github.com/tailscale/hujson"
)
type Config struct {
@@ -58,8 +59,13 @@ func (c *Config) LoadFile(path string) error {
return err
}
err = json.Unmarshal(b, &c)
b, err = hujson.Standardize(b)
if err != nil {
log.WithFields(log.Fields{"path": path, "error": err, "call": "hujson.Standardize"}).Errorf("")
return err
}
if err := json.Unmarshal(b, &c); err != nil {
log.WithFields(log.Fields{"path": path, "error": err, "call": "json.Unmarshal"}).Errorf("")
return err
}