blob: 25376c7b8c16272659528e77698b26cfe2490dc4 [file] [log] [blame]
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)
}