blob: 25376c7b8c16272659528e77698b26cfe2490dc4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
package internal
import (
"github.com/golang/protobuf/proto"
)
// GetUnrecognized fetches the bytes of unrecognized fields for the given message.
func GetUnrecognized(msg proto.Message) []byte {
return proto.MessageReflect(msg).GetUnknown()
}
// SetUnrecognized adds the given bytes to the unrecognized fields for the given message.
func SetUnrecognized(msg proto.Message, data []byte) {
refl := proto.MessageReflect(msg)
existing := refl.GetUnknown()
if len(existing) > 0 {
data = append(existing, data...)
}
refl.SetUnknown(data)
}
|