Skip to content

Commit dbdda84

Browse files
author
neosu
committed
remove sonic
1 parent 8067b08 commit dbdda84

File tree

5 files changed

+8
-11
lines changed

5 files changed

+8
-11
lines changed

codec/codec.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package codec
22

33
import (
4+
"encoding/json"
45
"reflect"
56

67
"github.com/gogf/gf/util/gconv"
@@ -9,8 +10,6 @@ import (
910
"github.com/metagogs/gogs/packet"
1011
"github.com/tidwall/gjson"
1112
"go.uber.org/zap"
12-
13-
"github.com/bytedance/sonic"
1413
)
1514

1615
// 7E 0A 41 00 02 00 00 0F 0A 0D 31 36 36 30 33 36 30 39 31 35 35 35 36
@@ -175,7 +174,7 @@ func (d *CodecHelper) decodeJSONWithoutHeader(data []byte) (*packet.Packet, erro
175174
return nil, ErrActionNotExist
176175
}
177176

178-
if err := sonic.Unmarshal(data, in); err != nil {
177+
if err := json.Unmarshal(data, in); err != nil {
179178
return nil, err
180179
}
181180

codec/codec_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"reflect"
77
"testing"
88

9-
"github.com/bytedance/sonic"
109
"github.com/gogf/gf/util/gconv"
1110
"github.com/metagogs/gogs/config"
1211
"github.com/metagogs/gogs/packet"
@@ -63,7 +62,7 @@ func jsonData(in interface{}) []byte {
6362
}
6463

6564
func jsonHeaderData(in interface{}) []byte {
66-
b, _ := sonic.Marshal(in)
65+
b, _ := json.Marshal(in)
6766
return b
6867
}
6968

codec/json_decode.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
package codec
22

33
import (
4-
"github.com/bytedance/sonic"
4+
"encoding/json"
55
)
66

77
type JSONDecode struct{}
88

99
func (c *JSONDecode) Decode(data []byte, in interface{}) error {
10-
if sonic.ConfigDefault.Valid(data) {
11-
return sonic.Unmarshal(data, in)
10+
if json.Valid(data) {
11+
return json.Unmarshal(data, in)
1212
}
1313
return ErrNotValidJSONType
1414
}
1515

1616
func (c *JSONDecode) String(in interface{}) string {
17-
msg, err := sonic.Marshal(in)
17+
msg, err := json.Marshal(in)
1818
if err != nil {
1919
return "proto encode error, " + err.Error()
2020
}

codec/json_encode.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
type JSONEncode struct{}
88

99
func (c *JSONEncode) Encode(in interface{}) ([]byte, error) {
10-
// 标准json的encode比sonic快,decode没有
1110
return json.Marshal(in)
1211
}
1312

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ go 1.21
44

55
require (
66
github.com/bwmarrin/snowflake v0.3.0
7-
github.com/bytedance/sonic v1.12.4
87
github.com/emicklei/proto v1.13.0
98
github.com/emirpasic/gods v1.18.1
109
github.com/ettle/strcase v0.2.0
@@ -29,6 +28,7 @@ require (
2928
atomicgo.dev/keyboard v0.2.9 // indirect
3029
atomicgo.dev/schedule v0.1.0 // indirect
3130
github.com/BurntSushi/toml v0.4.1 // indirect
31+
github.com/bytedance/sonic v1.12.4 // indirect
3232
github.com/bytedance/sonic/loader v0.2.0 // indirect
3333
github.com/cloudwego/base64x v0.1.4 // indirect
3434
github.com/cloudwego/iasm v0.2.0 // indirect

0 commit comments

Comments
 (0)