Skip to content

Commit

Permalink
Move to goccy/go-json instead of json-iterator/go.
Browse files Browse the repository at this point in the history
  • Loading branch information
dkorunic committed Dec 13, 2024
1 parent ea81338 commit d5a65a2
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 23 deletions.
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ toolchain go1.23.4

require (
github.com/fvbommel/sortorder v1.1.0
github.com/json-iterator/go v1.1.12
github.com/goccy/go-json v0.10.4
github.com/panotza/gosmc v1.0.0
github.com/spf13/cobra v1.8.1
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Expand Down
13 changes: 2 additions & 11 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fvbommel/sortorder v1.1.0 h1:fUmoe+HLsBTctBDoaBwpQo5N+nrCp8g/BjKb/6ZQmYw=
github.com/fvbommel/sortorder v1.1.0/go.mod h1:uk88iVf1ovNn1iLfgUVU2F9o5eO30ui720w+kxuqRs0=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/goccy/go-json v0.10.4 h1:JSwxQzIqKfmFX1swYPpUThQZp/Ka4wzJdK0LWVytLPM=
github.com/goccy/go-json v0.10.4/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/jedib0t/go-pretty/v6 v6.6.4 h1:B51RjA+Sytv0C0Je7PHGDXZBF2JpS5dZEWWRueBLP6U=
github.com/jedib0t/go-pretty/v6 v6.6.4/go.mod h1:zbn98qrYlh95FIhwwsbIip0LYpwSG8SUOScs+v9/t0E=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/panotza/gosmc v1.0.0 h1:xlszb8fU00ixVI5W00nnvicK66e6fKrVzffznnwqVlw=
github.com/panotza/gosmc v1.0.0/go.mod h1:LDwtbaiO0SB+duuYFnFx/AFulj42kVlXAhz1aQBk0tg=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand All @@ -30,8 +23,6 @@ github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
Expand Down
6 changes: 1 addition & 5 deletions output/jsonoutput.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"strconv"
"strings"

jsoniter "github.com/json-iterator/go"
"github.com/goccy/go-json"
)

type JSONOutput struct {
Expand Down Expand Up @@ -51,8 +51,6 @@ func format(d any) (any, error) {
return v, fmt.Errorf("not a map")
}

json := jsoniter.ConfigCompatibleWithStandardLibrary

for key, entry := range v {
t, err := json.Marshal(entry)
if err != nil {
Expand Down Expand Up @@ -100,7 +98,6 @@ func (jo JSONOutput) All() {
}
}

json := jsoniter.ConfigCompatibleWithStandardLibrary
out, _ := json.Marshal(data)
fmt.Println(string(out))
}
Expand Down Expand Up @@ -136,7 +133,6 @@ func (jo JSONOutput) print(v any) {
return
}

json := jsoniter.ConfigCompatibleWithStandardLibrary
out, _ := json.Marshal(data)
fmt.Println(string(out))
}
3 changes: 1 addition & 2 deletions output/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package output
import (
"github.com/dkorunic/iSMC/hid"
"github.com/dkorunic/iSMC/smc"
jsoniter "github.com/json-iterator/go"
"github.com/goccy/go-json"
)

// monkey patching for testing
Expand Down Expand Up @@ -92,7 +92,6 @@ func getVoltage() map[string]any {

// TODO replace with a variant from an utility package
func deepCopy(dest, src map[string]any) {
json := jsoniter.ConfigCompatibleWithStandardLibrary
jsonStr, _ := json.Marshal(src)
_ = json.Unmarshal(jsonStr, &dest)
}
Expand Down
3 changes: 1 addition & 2 deletions output/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"reflect"
"testing"

jsoniter "github.com/json-iterator/go"
"github.com/goccy/go-json"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -135,7 +135,6 @@ func Test_merge(t *testing.T) {
}

func toJson(src map[string]any) string {
json := jsoniter.ConfigCompatibleWithStandardLibrary
jsonStr, _ := json.Marshal(src)
return string(jsonStr)
}
Expand Down

0 comments on commit d5a65a2

Please sign in to comment.