diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/go/GenerateGoUtils.java b/protocol/src/main/java/com/zfoo/protocol/serializer/go/GenerateGoUtils.java index fd2d2f6c0..42c2e07db 100644 --- a/protocol/src/main/java/com/zfoo/protocol/serializer/go/GenerateGoUtils.java +++ b/protocol/src/main/java/com/zfoo/protocol/serializer/go/GenerateGoUtils.java @@ -192,7 +192,7 @@ private static String readObject(ProtocolRegistration registration) { if (field.isAnnotationPresent(Compatible.class)) { goBuilder.append(TAB ).append("if buffer.CompatibleRead(beforeReadIndex, length) {").append(LS); var compatibleReadObject = goSerializer(fieldRegistration.serializer()).readObject(goBuilder, 2, field, fieldRegistration); - goBuilder.append(TAB + TAB).append(StringUtils.format("packet.{} = {}", field.getName(), compatibleReadObject)).append(LS); + goBuilder.append(TAB + TAB).append(StringUtils.format("packet.{} = {}", StringUtils.capitalize(field.getName()), compatibleReadObject)).append(LS); goBuilder.append(TAB).append("}").append(LS); continue; } diff --git a/protocol/src/main/resources/go/ByteBuffer.go b/protocol/src/main/resources/go/ByteBuffer.go index 0e6e12847..b3be52d79 100644 --- a/protocol/src/main/resources/go/ByteBuffer.go +++ b/protocol/src/main/resources/go/ByteBuffer.go @@ -30,8 +30,7 @@ func (byteBuffer *ByteBuffer) AdjustPadding(predictionLength int, beforeWriteInd byteBuffer.WriteInt(length) byteBuffer.SetWriteOffset(currentWriteIndex) } else { - byteBuffer.SetWriteOffset(currentWriteIndex - length) - var byteArray = byteBuffer.ReadUBytes(length) + var byteArray = byteBuffer.buffer[(currentWriteIndex - length):currentWriteIndex] byteBuffer.SetWriteOffset(beforeWriteIndex) byteBuffer.WriteInt(length) byteBuffer.WriteUBytes(byteArray)