MCPcopy
hub / github.com/golang/protobuf / SetRawExtension

Function SetRawExtension

proto/extensions.go:254–271  ·  view source on GitHub ↗

SetRawExtension inserts b into the unknown fields of m. Deprecated: Use Message.ProtoReflect.SetUnknown instead.

(m Message, fnum int32, b []byte)

Source from the content-addressed store, hash-verified

252//
253// Deprecated: Use Message.ProtoReflect.SetUnknown instead.
254func SetRawExtension(m Message, fnum int32, b []byte) {
255 mr := MessageReflect(m)
256 if mr == nil || !mr.IsValid() {
257 return
258 }
259
260 // Verify that the raw field is valid.
261 for b0 := b; len(b0) > 0; {
262 num, _, n := protowire.ConsumeField(b0)
263 if int32(num) != fnum {
264 panic(fmt.Sprintf("mismatching field number: got %d, want %d", num, fnum))
265 }
266 b0 = b0[n:]
267 }
268
269 ClearExtension(m, &ExtensionDesc{Field: fnum})
270 mr.SetUnknown(append(mr.GetUnknown(), b...))
271}
272
273// ExtensionDescs returns a list of extension descriptors found in m,
274// containing descriptors for both populated extension fields in m and

Callers 2

initFunction · 0.92
newTestMessageFunction · 0.92

Calls 2

MessageReflectFunction · 0.85
ClearExtensionFunction · 0.85

Tested by 2

initFunction · 0.74
newTestMessageFunction · 0.74