Skip to content

Commit 9589384

Browse files
authored
refactor(encoding/gjson): change data parameter from type any to []byte (#3542)
1 parent cf74223 commit 9589384

21 files changed

+482
-394
lines changed

.golangci.yml

+3
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ linters-settings:
180180

181181
# https://golangci-lint.run/usage/linters/#govet
182182
govet:
183+
# Report about shadowed variables.
184+
# Default: false
185+
# check-shadowing: true
183186
# Settings per analyzer.
184187
settings:
185188
# Analyzer name, run `go tool vet help` to see all analyzers.

contrib/config/apollo/apollo.go

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/apolloconfig/agollo/v4"
1414
apolloConfig "github.com/apolloconfig/agollo/v4/env/config"
1515
"github.com/apolloconfig/agollo/v4/storage"
16+
1617
"github.com/gogf/gf/v2/encoding/gjson"
1718
"github.com/gogf/gf/v2/errors/gerror"
1819
"github.com/gogf/gf/v2/frame/g"

contrib/config/kubecm/kubecm.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func (c *Client) doUpdate(ctx context.Context, namespace string) (err error) {
138138
)
139139
}
140140
var j *gjson.Json
141-
if j, err = gjson.LoadContent(cm.Data[c.config.DataItem]); err != nil {
141+
if j, err = gjson.LoadContent([]byte(cm.Data[c.config.DataItem])); err != nil {
142142
return gerror.Wrapf(
143143
err,
144144
`parse config map item from %s[%s] failed`, c.config.ConfigMap, c.config.DataItem,

contrib/config/nacos/nacos.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func (c *Client) updateLocalValue() (err error) {
114114

115115
func (c *Client) doUpdate(content string) (err error) {
116116
var j *gjson.Json
117-
if j, err = gjson.LoadContent(content); err != nil {
117+
if j, err = gjson.LoadContent([]byte(content)); err != nil {
118118
return gerror.Wrap(err, `parse config map item from nacos failed`)
119119
}
120120
c.value.Set(j)

contrib/config/polaris/polaris.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func (c *Client) doUpdate(ctx context.Context) (err error) {
147147
return gerror.New("config file is empty")
148148
}
149149
var j *gjson.Json
150-
if j, err = gjson.LoadContent(c.client.GetContent()); err != nil {
150+
if j, err = gjson.LoadContent([]byte(c.client.GetContent())); err != nil {
151151
return gerror.Wrap(err, `parse config map item from polaris failed`)
152152
}
153153
c.value.Set(j)

contrib/drivers/mssql/mssql_z_unit_basic_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ func Test_DB_ToJson(t *testing.T) {
794794
}
795795

796796
// ToJson
797-
resultJson, err := gjson.LoadContent(result.Json())
797+
resultJson, err := gjson.LoadContent([]byte(result.Json()))
798798
if err != nil {
799799
gtest.Fatal(err)
800800
}

contrib/drivers/mysql/mysql_z_unit_core_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ func Test_DB_ToJson(t *testing.T) {
894894
}
895895

896896
// ToJson
897-
resultJson, err := gjson.LoadContent(result.Json())
897+
resultJson, err := gjson.LoadContent([]byte(result.Json()))
898898
if err != nil {
899899
gtest.Fatal(err)
900900
}

contrib/drivers/sqlite/sqlite_z_unit_core_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ func Test_DB_ToJson(t *testing.T) {
831831
}
832832

833833
// ToJson
834-
resultJson, err := gjson.LoadContent(result.Json())
834+
resultJson, err := gjson.LoadContent([]byte(result.Json()))
835835
if err != nil {
836836
gtest.Fatal(err)
837837
}

contrib/drivers/sqlitecgo/sqlitecgo_z_unit_core_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ func Test_DB_ToJson(t *testing.T) {
831831
}
832832

833833
// ToJson
834-
resultJson, err := gjson.LoadContent(result.Json())
834+
resultJson, err := gjson.LoadContent([]byte(result.Json()))
835835
if err != nil {
836836
gtest.Fatal(err)
837837
}

0 commit comments

Comments
 (0)