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

Function ClearAllExtensions

proto/extensions.go:96–109  ·  view source on GitHub ↗

ClearAllExtensions clears all extensions from m. This includes populated fields and unknown fields in the extension range.

(m Message)

Source from the content-addressed store, hash-verified

94// ClearAllExtensions clears all extensions from m.
95// This includes populated fields and unknown fields in the extension range.
96func ClearAllExtensions(m Message) {
97 mr := MessageReflect(m)
98 if mr == nil || !mr.IsValid() {
99 return
100 }
101
102 mr.Range(func(fd protoreflect.FieldDescriptor, _ protoreflect.Value) bool {
103 if fd.IsExtension() {
104 mr.Clear(fd)
105 }
106 return true
107 })
108 clearUnknown(mr, mr.Descriptor().ExtensionRanges())
109}
110
111// GetExtension retrieves a proto2 extended field from m.
112//

Callers 2

TestNilMessageFunction · 0.92
TestClearAllExtensionsFunction · 0.92

Calls 3

MessageReflectFunction · 0.85
clearUnknownFunction · 0.85
DescriptorMethod · 0.65

Tested by 2

TestNilMessageFunction · 0.74
TestClearAllExtensionsFunction · 0.74