From 360d0e861b4219cfc3aefc3e0bbaaf20217f1c92 Mon Sep 17 00:00:00 2001 From: injoyai <1113655791@qq.com> Date: Tue, 13 May 2025 11:16:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E5=BC=95=E7=94=A8=E5=BA=93?= =?UTF-8?q?=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 9 ++++----- protocol/frame.go | 8 ++++---- protocol/unit.go | 9 ++++----- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/go.mod b/go.mod index c0d7768..259520e 100644 --- a/go.mod +++ b/go.mod @@ -5,9 +5,9 @@ go 1.20 require ( github.com/glebarez/go-sqlite v1.22.0 github.com/go-sql-driver/mysql v1.7.0 - github.com/injoyai/base v1.0.18 - github.com/injoyai/conv v1.1.10 - github.com/injoyai/ios v0.0.4 + github.com/injoyai/base v1.2.7 + github.com/injoyai/conv v1.2.2 + github.com/injoyai/ios v0.0.7 github.com/injoyai/logs v1.0.9 github.com/robfig/cron/v3 v3.0.1 golang.org/x/text v0.16.0 @@ -22,14 +22,13 @@ require ( github.com/golang/snappy v0.0.4 // indirect github.com/google/uuid v1.5.0 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/kr/text v0.2.0 // indirect + github.com/kr/pretty v0.3.1 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pelletier/go-toml/v2 v2.1.1 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect - github.com/satori/go.uuid v1.2.0 // indirect github.com/stretchr/testify v1.9.0 // indirect github.com/syndtr/goleveldb v1.0.0 // indirect golang.org/x/sys v0.22.0 // indirect diff --git a/protocol/frame.go b/protocol/frame.go index b29d6f8..c2ab7c4 100644 --- a/protocol/frame.go +++ b/protocol/frame.go @@ -1,11 +1,11 @@ package protocol import ( + "bytes" "compress/zlib" "errors" "fmt" - "github.com/injoyai/base/bytes" - "github.com/injoyai/base/g" + "github.com/injoyai/base/types" "github.com/injoyai/conv" "io" ) @@ -19,7 +19,7 @@ const ( ) type Message interface { - Bytes() g.Bytes + Bytes() types.Bytes } /* @@ -39,7 +39,7 @@ type Frame struct { Data []byte //数据 } -func (this *Frame) Bytes() g.Bytes { +func (this *Frame) Bytes() types.Bytes { length := uint16(len(this.Data) + 2) data := make([]byte, 12+len(this.Data)) data[0] = Prefix diff --git a/protocol/unit.go b/protocol/unit.go index c6218e8..9b3fa13 100644 --- a/protocol/unit.go +++ b/protocol/unit.go @@ -3,7 +3,6 @@ package protocol import ( "bytes" "fmt" - bytes2 "github.com/injoyai/base/bytes" "github.com/injoyai/conv" "golang.org/x/text/encoding/simplifiedchinese" "golang.org/x/text/transform" @@ -15,12 +14,12 @@ import ( // String 字节先转小端,再转字符 func String(bs []byte) string { - return string(bytes2.Reverse(bs)) + return string(Reverse(bs)) } // Bytes 任意类型转小端字节 func Bytes(n any) []byte { - return bytes2.Reverse(conv.Bytes(n)) + return Reverse(conv.Bytes(n)) } // Reverse 字节倒序 @@ -34,12 +33,12 @@ func Reverse(bs []byte) []byte { // Uint32 字节通过小端方式转为uint32 func Uint32(bs []byte) uint32 { - return conv.Uint32(bytes2.Reverse(bs)) + return conv.Uint32(Reverse(bs)) } // Uint16 字节通过小端方式转为uint16 func Uint16(bs []byte) uint16 { - return conv.Uint16(bytes2.Reverse(bs)) + return conv.Uint16(Reverse(bs)) } func UTF8ToGBK(text []byte) []byte {