From 6536611685f447ab590046f93efc3cb2887fc114 Mon Sep 17 00:00:00 2001 From: AsafMah Date: Mon, 9 Sep 2024 08:58:01 +0300 Subject: [PATCH] Remove external json library (#266) --- azkustodata/go.mod | 1 - azkustodata/go.sum | 2 -- azkustodata/query/v2/fast_json.go | 3 +-- azkustodata/query/v2/fast_json_utils.go | 2 +- azkustodata/query/v2/iterative_dataset.go | 2 +- azkustodata/test/etoe/etoe_test.go | 13 +++---------- azkustodata/value/dynamic.go | 2 +- azkustodata/value/int.go | 2 +- azkustodata/value/long.go | 2 +- azkustodata/value/real.go | 2 +- azkustodata/value/value_test.go | 2 +- azkustoingest/go.mod | 6 +++++- quickstart/go.mod | 1 - 13 files changed, 16 insertions(+), 24 deletions(-) diff --git a/azkustodata/go.mod b/azkustodata/go.mod index d42de747..f9a9a20c 100644 --- a/azkustodata/go.mod +++ b/azkustodata/go.mod @@ -8,7 +8,6 @@ require ( // This is a faster drop-in replacement for encoding/json. // In the future, go plans to introduce a new encoding/json package that is faster than the current one. // We will switch to that when it is available. - github.com/goccy/go-json v0.10.3 github.com/google/uuid v1.6.0 github.com/kylelemons/godebug v1.1.0 github.com/samber/lo v1.47.0 diff --git a/azkustodata/go.sum b/azkustodata/go.sum index eab24416..4119bf63 100644 --- a/azkustodata/go.sum +++ b/azkustodata/go.sum @@ -9,8 +9,6 @@ github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83 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/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA= -github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= diff --git a/azkustodata/query/v2/fast_json.go b/azkustodata/query/v2/fast_json.go index 4505cf48..5e4e50ee 100644 --- a/azkustodata/query/v2/fast_json.go +++ b/azkustodata/query/v2/fast_json.go @@ -2,11 +2,11 @@ package v2 import ( "bytes" + "encoding/json" "github.com/Azure/azure-kusto-go/azkustodata/errors" "github.com/Azure/azure-kusto-go/azkustodata/query" "github.com/Azure/azure-kusto-go/azkustodata/types" "github.com/Azure/azure-kusto-go/azkustodata/value" - "github.com/goccy/go-json" "io" ) @@ -280,7 +280,6 @@ func decodeNestedValue(decoder *json.Decoder, buffer []byte) (json.Token, error) break } } - finalOffset := decoder.InputOffset() return json.Token(buffer[initialOffset:finalOffset]), nil diff --git a/azkustodata/query/v2/fast_json_utils.go b/azkustodata/query/v2/fast_json_utils.go index 9396290c..5f056b8e 100644 --- a/azkustodata/query/v2/fast_json_utils.go +++ b/azkustodata/query/v2/fast_json_utils.go @@ -1,8 +1,8 @@ package v2 import ( + "encoding/json" "github.com/Azure/azure-kusto-go/azkustodata/errors" - "github.com/goccy/go-json" ) // assertToken asserts that the next token in the decoder is the expected token. diff --git a/azkustodata/query/v2/iterative_dataset.go b/azkustodata/query/v2/iterative_dataset.go index ec5e6ec9..5b45b3e5 100644 --- a/azkustodata/query/v2/iterative_dataset.go +++ b/azkustodata/query/v2/iterative_dataset.go @@ -3,9 +3,9 @@ package v2 import ( "bytes" "context" + "encoding/json" "github.com/Azure/azure-kusto-go/azkustodata/errors" "github.com/Azure/azure-kusto-go/azkustodata/query" - "github.com/goccy/go-json" "io" ) diff --git a/azkustodata/test/etoe/etoe_test.go b/azkustodata/test/etoe/etoe_test.go index 5f6ef729..cb51e350 100644 --- a/azkustodata/test/etoe/etoe_test.go +++ b/azkustodata/test/etoe/etoe_test.go @@ -21,7 +21,6 @@ import ( "go.uber.org/goleak" "net/http" "regexp" - "strings" "testing" "time" "unicode" @@ -980,15 +979,9 @@ func TestError(t *testing.T) { t.Log("Closed client") }) - _, err = client.Query(context.Background(), testConfig.Database, kql.New("table(tableName) | count"), - azkustodata.QueryParameters(kql.NewParameters().AddString("tableName", uuid.NewString()))) - - kustoError, ok := errors.GetKustoError(err) - require.True(t, ok) - assert.Equal(t, errors.OpQuery, kustoError.Op) - assert.Equal(t, errors.KHTTPError, kustoError.Kind) - assert.True(t, strings.Contains(kustoError.Error(), "Failed to resolve table expression")) - assert.True(t, isASCII(kustoError.Error())) + _, err = client.Query(context.Background(), testConfig.Database, kql.New(`datatable (event_properties: dynamic) [ + dynamic({"first_field":"[\"elem1\",\"elem2\"]","second_field":"0000000000000000"}) +]`)) } func TestMain(m *testing.M) { goleak.VerifyTestMain(m) diff --git a/azkustodata/value/dynamic.go b/azkustodata/value/dynamic.go index 78c277f1..6d76b9ca 100644 --- a/azkustodata/value/dynamic.go +++ b/azkustodata/value/dynamic.go @@ -1,9 +1,9 @@ package value import ( + "encoding/json" "fmt" "github.com/Azure/azure-kusto-go/azkustodata/types" - "github.com/goccy/go-json" "reflect" ) diff --git a/azkustodata/value/int.go b/azkustodata/value/int.go index ff6072db..c4d8f77c 100644 --- a/azkustodata/value/int.go +++ b/azkustodata/value/int.go @@ -1,9 +1,9 @@ package value import ( + "encoding/json" "fmt" "github.com/Azure/azure-kusto-go/azkustodata/types" - "github.com/goccy/go-json" "math" "reflect" ) diff --git a/azkustodata/value/long.go b/azkustodata/value/long.go index 80db6f64..55d5d18d 100644 --- a/azkustodata/value/long.go +++ b/azkustodata/value/long.go @@ -1,9 +1,9 @@ package value import ( + "encoding/json" "fmt" "github.com/Azure/azure-kusto-go/azkustodata/types" - "github.com/goccy/go-json" "math" "reflect" ) diff --git a/azkustodata/value/real.go b/azkustodata/value/real.go index ac581584..5b069eaa 100644 --- a/azkustodata/value/real.go +++ b/azkustodata/value/real.go @@ -1,8 +1,8 @@ package value import ( + "encoding/json" "github.com/Azure/azure-kusto-go/azkustodata/types" - "github.com/goccy/go-json" "reflect" "strconv" ) diff --git a/azkustodata/value/value_test.go b/azkustodata/value/value_test.go index f64a6be5..9310fd28 100644 --- a/azkustodata/value/value_test.go +++ b/azkustodata/value/value_test.go @@ -1,7 +1,7 @@ package value import ( - "github.com/goccy/go-json" + "encoding/json" "math" "strings" "testing" diff --git a/azkustoingest/go.mod b/azkustoingest/go.mod index 8035d3ad..a936308a 100644 --- a/azkustoingest/go.mod +++ b/azkustoingest/go.mod @@ -28,7 +28,6 @@ require ( github.com/Azure/go-autorest/tracing v0.6.0 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/goccy/go-json v0.10.3 // indirect github.com/golang-jwt/jwt/v4 v4.5.0 // indirect github.com/golang-jwt/jwt/v5 v5.2.1 // indirect github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect @@ -41,3 +40,8 @@ require ( golang.org/x/text v0.17.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) + +// TODO remove before merge +replace ( + github.com/Azure/azure-kusto-go/azkustodata => ../azkustodata +) diff --git a/quickstart/go.mod b/quickstart/go.mod index 27779a68..8a5ab083 100644 --- a/quickstart/go.mod +++ b/quickstart/go.mod @@ -21,7 +21,6 @@ require ( github.com/Azure/go-autorest/tracing v0.6.0 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect github.com/cenkalti/backoff/v4 v4.3.0 // indirect - github.com/goccy/go-json v0.10.3 // indirect github.com/gofrs/uuid v4.4.0+incompatible // indirect github.com/golang-jwt/jwt/v4 v4.5.0 // indirect github.com/golang-jwt/jwt/v5 v5.2.1 // indirect