mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-10-13 04:15:22 +00:00
perf[golang]: golang协议首字母大写
This commit is contained in:
1 parent
1e1907cdef
commit
a68c948498
7 files changed
+99
-99
No files matched your search
@@ -1,9 +1,9 @@
|
||||
package protocol
|
||||
|
||||
type Message struct {
|
||||
code int
|
||||
message string
|
||||
module int8
|
||||
Code int
|
||||
Message string
|
||||
Module int8
|
||||
}
|
||||
|
||||
func (protocol Message) protocolId() int16 {
|
||||
@@ -15,9 +15,9 @@ func (protocol Message) write(buffer *ByteBuffer, packet any) {
|
||||
return
|
||||
}
|
||||
var message = packet.(*Message)
|
||||
buffer.WriteInt(message.code)
|
||||
buffer.WriteString(message.message)
|
||||
buffer.WriteByte(message.module)
|
||||
buffer.WriteInt(message.Code)
|
||||
buffer.WriteString(message.Message)
|
||||
buffer.WriteByte(message.Module)
|
||||
}
|
||||
|
||||
func (protocol Message) read(buffer *ByteBuffer) any {
|
||||
@@ -26,19 +26,19 @@ func (protocol Message) read(buffer *ByteBuffer) any {
|
||||
return packet
|
||||
}
|
||||
var result0 = buffer.ReadInt()
|
||||
packet.code = result0
|
||||
packet.Code = result0
|
||||
var result1 = buffer.ReadString()
|
||||
packet.message = result1
|
||||
packet.Message = result1
|
||||
var result2 = buffer.ReadByte()
|
||||
packet.module = result2
|
||||
packet.Module = result2
|
||||
return packet
|
||||
}
|
||||
|
||||
|
||||
type Error struct {
|
||||
errorCode int
|
||||
errorMessage string
|
||||
module int
|
||||
ErrorCode int
|
||||
ErrorMessage string
|
||||
Module int
|
||||
}
|
||||
|
||||
func (protocol Error) protocolId() int16 {
|
||||
@@ -50,9 +50,9 @@ func (protocol Error) write(buffer *ByteBuffer, packet any) {
|
||||
return
|
||||
}
|
||||
var message = packet.(*Error)
|
||||
buffer.WriteInt(message.errorCode)
|
||||
buffer.WriteString(message.errorMessage)
|
||||
buffer.WriteInt(message.module)
|
||||
buffer.WriteInt(message.ErrorCode)
|
||||
buffer.WriteString(message.ErrorMessage)
|
||||
buffer.WriteInt(message.Module)
|
||||
}
|
||||
|
||||
func (protocol Error) read(buffer *ByteBuffer) any {
|
||||
@@ -61,11 +61,11 @@ func (protocol Error) read(buffer *ByteBuffer) any {
|
||||
return packet
|
||||
}
|
||||
var result0 = buffer.ReadInt()
|
||||
packet.errorCode = result0
|
||||
packet.ErrorCode = result0
|
||||
var result1 = buffer.ReadString()
|
||||
packet.errorMessage = result1
|
||||
packet.ErrorMessage = result1
|
||||
var result2 = buffer.ReadInt()
|
||||
packet.module = result2
|
||||
packet.Module = result2
|
||||
return packet
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ func (protocol Ping) read(buffer *ByteBuffer) any {
|
||||
|
||||
|
||||
type Pong struct {
|
||||
time int64
|
||||
Time int64
|
||||
}
|
||||
|
||||
func (protocol Pong) protocolId() int16 {
|
||||
@@ -129,7 +129,7 @@ func (protocol Pong) write(buffer *ByteBuffer, packet any) {
|
||||
return
|
||||
}
|
||||
var message = packet.(*Pong)
|
||||
buffer.WriteLong(message.time)
|
||||
buffer.WriteLong(message.Time)
|
||||
}
|
||||
|
||||
func (protocol Pong) read(buffer *ByteBuffer) any {
|
||||
@@ -138,14 +138,14 @@ func (protocol Pong) read(buffer *ByteBuffer) any {
|
||||
return packet
|
||||
}
|
||||
var result0 = buffer.ReadLong()
|
||||
packet.time = result0
|
||||
packet.Time = result0
|
||||
return packet
|
||||
}
|
||||
|
||||
|
||||
type PairLong struct {
|
||||
key int64
|
||||
value int64
|
||||
Key int64
|
||||
Value int64
|
||||
}
|
||||
|
||||
func (protocol PairLong) protocolId() int16 {
|
||||
@@ -157,8 +157,8 @@ func (protocol PairLong) write(buffer *ByteBuffer, packet any) {
|
||||
return
|
||||
}
|
||||
var message = packet.(*PairLong)
|
||||
buffer.WriteLong(message.key)
|
||||
buffer.WriteLong(message.value)
|
||||
buffer.WriteLong(message.Key)
|
||||
buffer.WriteLong(message.Value)
|
||||
}
|
||||
|
||||
func (protocol PairLong) read(buffer *ByteBuffer) any {
|
||||
@@ -167,16 +167,16 @@ func (protocol PairLong) read(buffer *ByteBuffer) any {
|
||||
return packet
|
||||
}
|
||||
var result0 = buffer.ReadLong()
|
||||
packet.key = result0
|
||||
packet.Key = result0
|
||||
var result1 = buffer.ReadLong()
|
||||
packet.value = result1
|
||||
packet.Value = result1
|
||||
return packet
|
||||
}
|
||||
|
||||
|
||||
type PairString struct {
|
||||
key string
|
||||
value string
|
||||
Key string
|
||||
Value string
|
||||
}
|
||||
|
||||
func (protocol PairString) protocolId() int16 {
|
||||
@@ -188,8 +188,8 @@ func (protocol PairString) write(buffer *ByteBuffer, packet any) {
|
||||
return
|
||||
}
|
||||
var message = packet.(*PairString)
|
||||
buffer.WriteString(message.key)
|
||||
buffer.WriteString(message.value)
|
||||
buffer.WriteString(message.Key)
|
||||
buffer.WriteString(message.Value)
|
||||
}
|
||||
|
||||
func (protocol PairString) read(buffer *ByteBuffer) any {
|
||||
@@ -198,16 +198,16 @@ func (protocol PairString) read(buffer *ByteBuffer) any {
|
||||
return packet
|
||||
}
|
||||
var result0 = buffer.ReadString()
|
||||
packet.key = result0
|
||||
packet.Key = result0
|
||||
var result1 = buffer.ReadString()
|
||||
packet.value = result1
|
||||
packet.Value = result1
|
||||
return packet
|
||||
}
|
||||
|
||||
|
||||
type PairLS struct {
|
||||
key int64
|
||||
value string
|
||||
Key int64
|
||||
Value string
|
||||
}
|
||||
|
||||
func (protocol PairLS) protocolId() int16 {
|
||||
@@ -219,8 +219,8 @@ func (protocol PairLS) write(buffer *ByteBuffer, packet any) {
|
||||
return
|
||||
}
|
||||
var message = packet.(*PairLS)
|
||||
buffer.WriteLong(message.key)
|
||||
buffer.WriteString(message.value)
|
||||
buffer.WriteLong(message.Key)
|
||||
buffer.WriteString(message.Value)
|
||||
}
|
||||
|
||||
func (protocol PairLS) read(buffer *ByteBuffer) any {
|
||||
@@ -229,17 +229,17 @@ func (protocol PairLS) read(buffer *ByteBuffer) any {
|
||||
return packet
|
||||
}
|
||||
var result0 = buffer.ReadLong()
|
||||
packet.key = result0
|
||||
packet.Key = result0
|
||||
var result1 = buffer.ReadString()
|
||||
packet.value = result1
|
||||
packet.Value = result1
|
||||
return packet
|
||||
}
|
||||
|
||||
|
||||
type TripleLong struct {
|
||||
left int64
|
||||
middle int64
|
||||
right int64
|
||||
Left int64
|
||||
Middle int64
|
||||
Right int64
|
||||
}
|
||||
|
||||
func (protocol TripleLong) protocolId() int16 {
|
||||
@@ -251,9 +251,9 @@ func (protocol TripleLong) write(buffer *ByteBuffer, packet any) {
|
||||
return
|
||||
}
|
||||
var message = packet.(*TripleLong)
|
||||
buffer.WriteLong(message.left)
|
||||
buffer.WriteLong(message.middle)
|
||||
buffer.WriteLong(message.right)
|
||||
buffer.WriteLong(message.Left)
|
||||
buffer.WriteLong(message.Middle)
|
||||
buffer.WriteLong(message.Right)
|
||||
}
|
||||
|
||||
func (protocol TripleLong) read(buffer *ByteBuffer) any {
|
||||
@@ -262,19 +262,19 @@ func (protocol TripleLong) read(buffer *ByteBuffer) any {
|
||||
return packet
|
||||
}
|
||||
var result0 = buffer.ReadLong()
|
||||
packet.left = result0
|
||||
packet.Left = result0
|
||||
var result1 = buffer.ReadLong()
|
||||
packet.middle = result1
|
||||
packet.Middle = result1
|
||||
var result2 = buffer.ReadLong()
|
||||
packet.right = result2
|
||||
packet.Right = result2
|
||||
return packet
|
||||
}
|
||||
|
||||
|
||||
type TripleString struct {
|
||||
left string
|
||||
middle string
|
||||
right string
|
||||
Left string
|
||||
Middle string
|
||||
Right string
|
||||
}
|
||||
|
||||
func (protocol TripleString) protocolId() int16 {
|
||||
@@ -286,9 +286,9 @@ func (protocol TripleString) write(buffer *ByteBuffer, packet any) {
|
||||
return
|
||||
}
|
||||
var message = packet.(*TripleString)
|
||||
buffer.WriteString(message.left)
|
||||
buffer.WriteString(message.middle)
|
||||
buffer.WriteString(message.right)
|
||||
buffer.WriteString(message.Left)
|
||||
buffer.WriteString(message.Middle)
|
||||
buffer.WriteString(message.Right)
|
||||
}
|
||||
|
||||
func (protocol TripleString) read(buffer *ByteBuffer) any {
|
||||
@@ -297,19 +297,19 @@ func (protocol TripleString) read(buffer *ByteBuffer) any {
|
||||
return packet
|
||||
}
|
||||
var result0 = buffer.ReadString()
|
||||
packet.left = result0
|
||||
packet.Left = result0
|
||||
var result1 = buffer.ReadString()
|
||||
packet.middle = result1
|
||||
packet.Middle = result1
|
||||
var result2 = buffer.ReadString()
|
||||
packet.right = result2
|
||||
packet.Right = result2
|
||||
return packet
|
||||
}
|
||||
|
||||
|
||||
type TripleLSS struct {
|
||||
left int64
|
||||
middle string
|
||||
right string
|
||||
Left int64
|
||||
Middle string
|
||||
Right string
|
||||
}
|
||||
|
||||
func (protocol TripleLSS) protocolId() int16 {
|
||||
@@ -321,9 +321,9 @@ func (protocol TripleLSS) write(buffer *ByteBuffer, packet any) {
|
||||
return
|
||||
}
|
||||
var message = packet.(*TripleLSS)
|
||||
buffer.WriteLong(message.left)
|
||||
buffer.WriteString(message.middle)
|
||||
buffer.WriteString(message.right)
|
||||
buffer.WriteLong(message.Left)
|
||||
buffer.WriteString(message.Middle)
|
||||
buffer.WriteString(message.Right)
|
||||
}
|
||||
|
||||
func (protocol TripleLSS) read(buffer *ByteBuffer) any {
|
||||
@@ -332,10 +332,10 @@ func (protocol TripleLSS) read(buffer *ByteBuffer) any {
|
||||
return packet
|
||||
}
|
||||
var result0 = buffer.ReadLong()
|
||||
packet.left = result0
|
||||
packet.Left = result0
|
||||
var result1 = buffer.ReadString()
|
||||
packet.middle = result1
|
||||
packet.Middle = result1
|
||||
var result2 = buffer.ReadString()
|
||||
packet.right = result2
|
||||
packet.Right = result2
|
||||
return packet
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package protocol
|
||||
|
||||
type GatewayToProviderRequest struct {
|
||||
message string
|
||||
Message string
|
||||
}
|
||||
|
||||
func (protocol GatewayToProviderRequest) protocolId() int16 {
|
||||
@@ -13,7 +13,7 @@ func (protocol GatewayToProviderRequest) write(buffer *ByteBuffer, packet any) {
|
||||
return
|
||||
}
|
||||
var message = packet.(*GatewayToProviderRequest)
|
||||
buffer.WriteString(message.message)
|
||||
buffer.WriteString(message.Message)
|
||||
}
|
||||
|
||||
func (protocol GatewayToProviderRequest) read(buffer *ByteBuffer) any {
|
||||
@@ -22,13 +22,13 @@ func (protocol GatewayToProviderRequest) read(buffer *ByteBuffer) any {
|
||||
return packet
|
||||
}
|
||||
var result0 = buffer.ReadString()
|
||||
packet.message = result0
|
||||
packet.Message = result0
|
||||
return packet
|
||||
}
|
||||
|
||||
|
||||
type GatewayToProviderResponse struct {
|
||||
message string
|
||||
Message string
|
||||
}
|
||||
|
||||
func (protocol GatewayToProviderResponse) protocolId() int16 {
|
||||
@@ -40,7 +40,7 @@ func (protocol GatewayToProviderResponse) write(buffer *ByteBuffer, packet any)
|
||||
return
|
||||
}
|
||||
var message = packet.(*GatewayToProviderResponse)
|
||||
buffer.WriteString(message.message)
|
||||
buffer.WriteString(message.Message)
|
||||
}
|
||||
|
||||
func (protocol GatewayToProviderResponse) read(buffer *ByteBuffer) any {
|
||||
@@ -49,6 +49,6 @@ func (protocol GatewayToProviderResponse) read(buffer *ByteBuffer) any {
|
||||
return packet
|
||||
}
|
||||
var result0 = buffer.ReadString()
|
||||
packet.message = result0
|
||||
packet.Message = result0
|
||||
return packet
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package protocol
|
||||
|
||||
type JProtobufHelloRequest struct {
|
||||
message string
|
||||
Message string
|
||||
}
|
||||
|
||||
func (protocol JProtobufHelloRequest) protocolId() int16 {
|
||||
@@ -13,7 +13,7 @@ func (protocol JProtobufHelloRequest) write(buffer *ByteBuffer, packet any) {
|
||||
return
|
||||
}
|
||||
var message = packet.(*JProtobufHelloRequest)
|
||||
buffer.WriteString(message.message)
|
||||
buffer.WriteString(message.Message)
|
||||
}
|
||||
|
||||
func (protocol JProtobufHelloRequest) read(buffer *ByteBuffer) any {
|
||||
@@ -22,13 +22,13 @@ func (protocol JProtobufHelloRequest) read(buffer *ByteBuffer) any {
|
||||
return packet
|
||||
}
|
||||
var result0 = buffer.ReadString()
|
||||
packet.message = result0
|
||||
packet.Message = result0
|
||||
return packet
|
||||
}
|
||||
|
||||
|
||||
type JProtobufHelloResponse struct {
|
||||
message string
|
||||
Message string
|
||||
}
|
||||
|
||||
func (protocol JProtobufHelloResponse) protocolId() int16 {
|
||||
@@ -40,7 +40,7 @@ func (protocol JProtobufHelloResponse) write(buffer *ByteBuffer, packet any) {
|
||||
return
|
||||
}
|
||||
var message = packet.(*JProtobufHelloResponse)
|
||||
buffer.WriteString(message.message)
|
||||
buffer.WriteString(message.Message)
|
||||
}
|
||||
|
||||
func (protocol JProtobufHelloResponse) read(buffer *ByteBuffer) any {
|
||||
@@ -49,6 +49,6 @@ func (protocol JProtobufHelloResponse) read(buffer *ByteBuffer) any {
|
||||
return packet
|
||||
}
|
||||
var result0 = buffer.ReadString()
|
||||
packet.message = result0
|
||||
packet.Message = result0
|
||||
return packet
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package protocol
|
||||
|
||||
type JsonHelloRequest struct {
|
||||
message string
|
||||
Message string
|
||||
}
|
||||
|
||||
func (protocol JsonHelloRequest) protocolId() int16 {
|
||||
@@ -13,7 +13,7 @@ func (protocol JsonHelloRequest) write(buffer *ByteBuffer, packet any) {
|
||||
return
|
||||
}
|
||||
var message = packet.(*JsonHelloRequest)
|
||||
buffer.WriteString(message.message)
|
||||
buffer.WriteString(message.Message)
|
||||
}
|
||||
|
||||
func (protocol JsonHelloRequest) read(buffer *ByteBuffer) any {
|
||||
@@ -22,13 +22,13 @@ func (protocol JsonHelloRequest) read(buffer *ByteBuffer) any {
|
||||
return packet
|
||||
}
|
||||
var result0 = buffer.ReadString()
|
||||
packet.message = result0
|
||||
packet.Message = result0
|
||||
return packet
|
||||
}
|
||||
|
||||
|
||||
type JsonHelloResponse struct {
|
||||
message string
|
||||
Message string
|
||||
}
|
||||
|
||||
func (protocol JsonHelloResponse) protocolId() int16 {
|
||||
@@ -40,7 +40,7 @@ func (protocol JsonHelloResponse) write(buffer *ByteBuffer, packet any) {
|
||||
return
|
||||
}
|
||||
var message = packet.(*JsonHelloResponse)
|
||||
buffer.WriteString(message.message)
|
||||
buffer.WriteString(message.Message)
|
||||
}
|
||||
|
||||
func (protocol JsonHelloResponse) read(buffer *ByteBuffer) any {
|
||||
@@ -49,6 +49,6 @@ func (protocol JsonHelloResponse) read(buffer *ByteBuffer) any {
|
||||
return packet
|
||||
}
|
||||
var result0 = buffer.ReadString()
|
||||
packet.message = result0
|
||||
packet.Message = result0
|
||||
return packet
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package protocol
|
||||
|
||||
type TcpHelloRequest struct {
|
||||
message string
|
||||
Message string
|
||||
}
|
||||
|
||||
func (protocol TcpHelloRequest) protocolId() int16 {
|
||||
@@ -13,7 +13,7 @@ func (protocol TcpHelloRequest) write(buffer *ByteBuffer, packet any) {
|
||||
return
|
||||
}
|
||||
var message = packet.(*TcpHelloRequest)
|
||||
buffer.WriteString(message.message)
|
||||
buffer.WriteString(message.Message)
|
||||
}
|
||||
|
||||
func (protocol TcpHelloRequest) read(buffer *ByteBuffer) any {
|
||||
@@ -22,13 +22,13 @@ func (protocol TcpHelloRequest) read(buffer *ByteBuffer) any {
|
||||
return packet
|
||||
}
|
||||
var result0 = buffer.ReadString()
|
||||
packet.message = result0
|
||||
packet.Message = result0
|
||||
return packet
|
||||
}
|
||||
|
||||
|
||||
type TcpHelloResponse struct {
|
||||
message string
|
||||
Message string
|
||||
}
|
||||
|
||||
func (protocol TcpHelloResponse) protocolId() int16 {
|
||||
@@ -40,7 +40,7 @@ func (protocol TcpHelloResponse) write(buffer *ByteBuffer, packet any) {
|
||||
return
|
||||
}
|
||||
var message = packet.(*TcpHelloResponse)
|
||||
buffer.WriteString(message.message)
|
||||
buffer.WriteString(message.Message)
|
||||
}
|
||||
|
||||
func (protocol TcpHelloResponse) read(buffer *ByteBuffer) any {
|
||||
@@ -49,6 +49,6 @@ func (protocol TcpHelloResponse) read(buffer *ByteBuffer) any {
|
||||
return packet
|
||||
}
|
||||
var result0 = buffer.ReadString()
|
||||
packet.message = result0
|
||||
packet.Message = result0
|
||||
return packet
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package protocol
|
||||
|
||||
type UdpHelloRequest struct {
|
||||
message string
|
||||
Message string
|
||||
}
|
||||
|
||||
func (protocol UdpHelloRequest) protocolId() int16 {
|
||||
@@ -13,7 +13,7 @@ func (protocol UdpHelloRequest) write(buffer *ByteBuffer, packet any) {
|
||||
return
|
||||
}
|
||||
var message = packet.(*UdpHelloRequest)
|
||||
buffer.WriteString(message.message)
|
||||
buffer.WriteString(message.Message)
|
||||
}
|
||||
|
||||
func (protocol UdpHelloRequest) read(buffer *ByteBuffer) any {
|
||||
@@ -22,13 +22,13 @@ func (protocol UdpHelloRequest) read(buffer *ByteBuffer) any {
|
||||
return packet
|
||||
}
|
||||
var result0 = buffer.ReadString()
|
||||
packet.message = result0
|
||||
packet.Message = result0
|
||||
return packet
|
||||
}
|
||||
|
||||
|
||||
type UdpHelloResponse struct {
|
||||
message string
|
||||
Message string
|
||||
}
|
||||
|
||||
func (protocol UdpHelloResponse) protocolId() int16 {
|
||||
@@ -40,7 +40,7 @@ func (protocol UdpHelloResponse) write(buffer *ByteBuffer, packet any) {
|
||||
return
|
||||
}
|
||||
var message = packet.(*UdpHelloResponse)
|
||||
buffer.WriteString(message.message)
|
||||
buffer.WriteString(message.Message)
|
||||
}
|
||||
|
||||
func (protocol UdpHelloResponse) read(buffer *ByteBuffer) any {
|
||||
@@ -49,6 +49,6 @@ func (protocol UdpHelloResponse) read(buffer *ByteBuffer) any {
|
||||
return packet
|
||||
}
|
||||
var result0 = buffer.ReadString()
|
||||
packet.message = result0
|
||||
packet.Message = result0
|
||||
return packet
|
||||
}
|
||||
@@ -156,7 +156,7 @@ public abstract class GenerateGoUtils {
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
Field field = fields[i];
|
||||
IFieldRegistration fieldRegistration = fieldRegistrations[i];
|
||||
var fieldName = field.getName();
|
||||
var fieldName = StringUtils.capitalize(field.getName());
|
||||
var fieldType = goSerializer(fieldRegistration.serializer()).fieldType(field, fieldRegistration);
|
||||
|
||||
var propertyFullName = StringUtils.format("{} {}", fieldName, fieldType);
|
||||
@@ -177,7 +177,7 @@ public abstract class GenerateGoUtils {
|
||||
for (var i = 0; i < fields.length; i++) {
|
||||
var field = fields[i];
|
||||
var fieldRegistration = fieldRegistrations[i];
|
||||
goSerializer(fieldRegistration.serializer()).writeObject(goBuilder, "message." + field.getName(), 1, field, fieldRegistration);
|
||||
goSerializer(fieldRegistration.serializer()).writeObject(goBuilder, "message." + StringUtils.capitalize(field.getName()), 1, field, fieldRegistration);
|
||||
}
|
||||
return goBuilder.toString();
|
||||
}
|
||||
@@ -197,7 +197,7 @@ public abstract class GenerateGoUtils {
|
||||
goBuilder.append(TAB).append("}").append(LS);
|
||||
}
|
||||
var readObject = goSerializer(fieldRegistration.serializer()).readObject(goBuilder, 1, field, fieldRegistration);
|
||||
goBuilder.append(TAB).append(StringUtils.format("packet.{} = {}", field.getName(), readObject)).append(LS);
|
||||
goBuilder.append(TAB).append(StringUtils.format("packet.{} = {}", StringUtils.capitalize(field.getName()), readObject)).append(LS);
|
||||
}
|
||||
return goBuilder.toString();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user