From b65713aaf1e7effe91b5809b529e4dbd0cdea5c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Haris=20Osmanagi=C4=87?= Date: Thu, 15 Feb 2024 13:27:09 +0100 Subject: [PATCH] Use goccy/go-json instead of encoding/json (#1383) --- .golangci.yml | 4 +++- pkg/foundation/grpcutil/interceptor_test.go | 2 +- pkg/pipeline/store.go | 2 +- pkg/processor/procbuiltin/httprequest.go | 2 +- pkg/processor/procbuiltin/httprequest_test.go | 2 +- pkg/processor/procbuiltin/parsejson.go | 2 +- pkg/processor/procbuiltin/unwrap.go | 2 +- pkg/processor/schemaregistry/client_fake_test.go | 2 +- pkg/processor/store.go | 2 +- pkg/provisioning/config/yaml/v2/model_test.go | 2 +- pkg/record/record.go | 2 +- 11 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 4aa5db494..1cc408496 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -13,7 +13,9 @@ linters-settings: - pkg: golang.org/x/xerrors desc: To accommodate for custom error creation and handling use Conduit's 'cerrors' package instead. - pkg: github.com/golang/mock - desc: github.com/golang/mock is deprecated, use go.uber.org/mock instead + desc: github.com/golang/mock is deprecated, use go.uber.org/mock instead. + - pkg: encoding/json + desc: github.com/goccy/go-json is preferred for performance reasons. gofmt: simplify: false govet: diff --git a/pkg/foundation/grpcutil/interceptor_test.go b/pkg/foundation/grpcutil/interceptor_test.go index f6441e63a..91687a852 100644 --- a/pkg/foundation/grpcutil/interceptor_test.go +++ b/pkg/foundation/grpcutil/interceptor_test.go @@ -17,11 +17,11 @@ package grpcutil import ( "bytes" "context" - "encoding/json" "testing" "github.com/conduitio/conduit/pkg/foundation/ctxutil" "github.com/conduitio/conduit/pkg/foundation/log" + "github.com/goccy/go-json" "github.com/google/uuid" "github.com/matryer/is" "github.com/rs/zerolog" diff --git a/pkg/pipeline/store.go b/pkg/pipeline/store.go index abf253292..2c2cd8bda 100644 --- a/pkg/pipeline/store.go +++ b/pkg/pipeline/store.go @@ -17,11 +17,11 @@ package pipeline import ( "bytes" "context" - "encoding/json" "strings" "github.com/conduitio/conduit/pkg/foundation/cerrors" "github.com/conduitio/conduit/pkg/foundation/database" + "github.com/goccy/go-json" ) const ( diff --git a/pkg/processor/procbuiltin/httprequest.go b/pkg/processor/procbuiltin/httprequest.go index 64e6d056b..e3be2e91c 100644 --- a/pkg/processor/procbuiltin/httprequest.go +++ b/pkg/processor/procbuiltin/httprequest.go @@ -17,7 +17,6 @@ package procbuiltin import ( "bytes" "context" - "encoding/json" "io" "net/http" "net/url" @@ -26,6 +25,7 @@ import ( "github.com/conduitio/conduit/pkg/foundation/cerrors" "github.com/conduitio/conduit/pkg/processor" "github.com/conduitio/conduit/pkg/record" + "github.com/goccy/go-json" "github.com/jpillora/backoff" ) diff --git a/pkg/processor/procbuiltin/httprequest_test.go b/pkg/processor/procbuiltin/httprequest_test.go index 3b0e8d761..fecc8e777 100644 --- a/pkg/processor/procbuiltin/httprequest_test.go +++ b/pkg/processor/procbuiltin/httprequest_test.go @@ -16,7 +16,6 @@ package procbuiltin import ( "context" - "encoding/json" "io" "net/http" "net/http/httptest" @@ -24,6 +23,7 @@ import ( "github.com/conduitio/conduit/pkg/processor" "github.com/conduitio/conduit/pkg/record" + "github.com/goccy/go-json" "github.com/matryer/is" ) diff --git a/pkg/processor/procbuiltin/parsejson.go b/pkg/processor/procbuiltin/parsejson.go index 0ffcc1288..5c92e4350 100644 --- a/pkg/processor/procbuiltin/parsejson.go +++ b/pkg/processor/procbuiltin/parsejson.go @@ -16,11 +16,11 @@ package procbuiltin import ( "context" - "encoding/json" "github.com/conduitio/conduit/pkg/foundation/cerrors" "github.com/conduitio/conduit/pkg/processor" "github.com/conduitio/conduit/pkg/record" + "github.com/goccy/go-json" ) const ( diff --git a/pkg/processor/procbuiltin/unwrap.go b/pkg/processor/procbuiltin/unwrap.go index 8cd396c8b..69c76646a 100644 --- a/pkg/processor/procbuiltin/unwrap.go +++ b/pkg/processor/procbuiltin/unwrap.go @@ -17,7 +17,6 @@ package procbuiltin import ( "context" "encoding/base64" - "encoding/json" "fmt" "time" @@ -25,6 +24,7 @@ import ( "github.com/conduitio/conduit/pkg/foundation/multierror" "github.com/conduitio/conduit/pkg/processor" "github.com/conduitio/conduit/pkg/record" + "github.com/goccy/go-json" ) type unwrapProcessor struct { diff --git a/pkg/processor/schemaregistry/client_fake_test.go b/pkg/processor/schemaregistry/client_fake_test.go index 43f99a950..594b32283 100644 --- a/pkg/processor/schemaregistry/client_fake_test.go +++ b/pkg/processor/schemaregistry/client_fake_test.go @@ -17,7 +17,6 @@ package schemaregistry import ( - "encoding/json" "net/http" "net/http/httptest" "strconv" @@ -27,6 +26,7 @@ import ( "github.com/conduitio/conduit/pkg/foundation/cerrors" "github.com/conduitio/conduit/pkg/processor/schemaregistry/internal" + "github.com/goccy/go-json" "github.com/lovromazgon/franz-go/pkg/sr" ) diff --git a/pkg/processor/store.go b/pkg/processor/store.go index 12714e6ff..d62767037 100644 --- a/pkg/processor/store.go +++ b/pkg/processor/store.go @@ -17,11 +17,11 @@ package processor import ( "bytes" "context" - "encoding/json" "strings" "github.com/conduitio/conduit/pkg/foundation/cerrors" "github.com/conduitio/conduit/pkg/foundation/database" + "github.com/goccy/go-json" ) const ( diff --git a/pkg/provisioning/config/yaml/v2/model_test.go b/pkg/provisioning/config/yaml/v2/model_test.go index e49d1b3d9..f20f5f0eb 100644 --- a/pkg/provisioning/config/yaml/v2/model_test.go +++ b/pkg/provisioning/config/yaml/v2/model_test.go @@ -15,9 +15,9 @@ package v2 import ( - "encoding/json" "testing" + "github.com/goccy/go-json" "github.com/matryer/is" ) diff --git a/pkg/record/record.go b/pkg/record/record.go index 019050ae3..8b88aaf47 100644 --- a/pkg/record/record.go +++ b/pkg/record/record.go @@ -19,13 +19,13 @@ package record import ( "bytes" "encoding/base64" - "encoding/json" "fmt" "strconv" "strings" "github.com/conduitio/conduit/pkg/foundation/cerrors" "github.com/conduitio/conduit/pkg/record/schema" + "github.com/goccy/go-json" ) const (