protobuf解析优化

This commit is contained in:
hahwu 2025-12-16 19:06:45 +08:00
parent a3d3c2621f
commit 87668bc9ed

View File

@ -4,11 +4,12 @@ import (
"encoding/binary"
"errors"
"fmt"
"google.golang.org/protobuf/proto"
"math"
"reflect"
"server/pkg/github.com/name5566/leaf/chanrpc"
"server/pkg/github.com/name5566/leaf/log"
"google.golang.org/protobuf/proto"
)
// -------------------------
@ -174,7 +175,11 @@ func (p *Processor) Marshal(msg interface{}) ([][]byte, error) {
}
// data
data, err := proto.Marshal(msg.(proto.Message))
opts := proto.MarshalOptions{
Deterministic: true,
}
data, err := opts.Marshal(msg.(proto.Message))
return [][]byte{id, data}, err
}