diff --git a/go.mod b/go.mod index bba3a9b84..45342effb 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,8 @@ module github.com/wavetermdev/waveterm -go 1.22.4 +go 1.23 + +toolchain go1.23.4 require ( github.com/alexflint/go-filemutex v1.3.0 @@ -21,6 +23,7 @@ require ( github.com/shirou/gopsutil/v4 v4.24.10 github.com/skeema/knownhosts v1.3.0 github.com/spf13/cobra v1.8.1 + github.com/tailscale/hujson v0.0.0-20241010212012-29efb4a0184b github.com/ubuntu/gowsl v0.0.0-20240906163211-049fd49bd93b github.com/wavetermdev/htmltoken v0.2.0 golang.org/x/crypto v0.29.0 diff --git a/go.sum b/go.sum index e36da9cf9..19edd082b 100644 --- a/go.sum +++ b/go.sum @@ -78,6 +78,8 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/tailscale/hujson v0.0.0-20241010212012-29efb4a0184b h1:MNaGusDfB1qxEsl6iVb33Gbe777IKzPP5PDta0xGC8M= +github.com/tailscale/hujson v0.0.0-20241010212012-29efb4a0184b/go.mod h1:EbW0wDK/qEUYI0A5bqq0C2kF8JTQwWONmGDBbzsxxHo= github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= diff --git a/pkg/wconfig/settingsconfig.go b/pkg/wconfig/settingsconfig.go index de046b578..845767fa9 100644 --- a/pkg/wconfig/settingsconfig.go +++ b/pkg/wconfig/settingsconfig.go @@ -15,6 +15,7 @@ import ( "sort" "strings" + "github.com/tailscale/hujson" "github.com/wavetermdev/waveterm/pkg/util/utilfn" "github.com/wavetermdev/waveterm/pkg/wavebase" "github.com/wavetermdev/waveterm/pkg/waveobj" @@ -153,7 +154,11 @@ func readConfigHelper(fileName string, barr []byte, readErr error) (waveobj.Meta return nil, cerrs } var rtn waveobj.MetaMapType - err := json.Unmarshal(barr, &rtn) + barr, err := hujson.Standardize(barr) + if err != nil { + cerrs = append(cerrs, ConfigError{File: fileName, Err: err.Error()}) + } + err = json.Unmarshal(barr, &rtn) if err != nil { if syntaxErr, ok := err.(*json.SyntaxError); ok { offset := syntaxErr.Offset @@ -407,7 +412,7 @@ func jsonMarshalConfigInOrder(m waveobj.MetaMapType) ([]byte, error) { var buf bytes.Buffer orderedKeys := orderConfigKeys(m) buf.WriteString("{\n") - for idx, key := range orderedKeys { + for _, key := range orderedKeys { val := m[key] keyBarr, err := json.Marshal(key) if err != nil { @@ -422,9 +427,7 @@ func jsonMarshalConfigInOrder(m waveobj.MetaMapType) ([]byte, error) { buf.Write(keyBarr) buf.WriteString(": ") buf.Write(valBarr) - if idx < len(orderedKeys)-1 { - buf.WriteString(",") - } + buf.WriteString(",") buf.WriteString("\n") } buf.WriteString("}")