use hujson for config file
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user