MCPcopy
hub / github.com/protocolbuffers/protobuf-go / List

Interface List

reflect/protoreflect/value.go:180–226  ·  view source on GitHub ↗

List is a zero-indexed, ordered list. The element [Value] type is determined by [FieldDescriptor.Kind]. Providing a [Value] that is invalid or of an incorrect type panics.

Source from the content-addressed store, hash-verified

178// The element [Value] type is determined by [FieldDescriptor.Kind].
179// Providing a [Value] that is invalid or of an incorrect type panics.
180type List interface {
181 // Len reports the number of entries in the List.
182 // Get, Set, and Truncate panic with out of bound indexes.
183 Len() int
184
185 // Get retrieves the value at the given index.
186 // It never returns an invalid value.
187 Get(int) Value
188
189 // Set stores a value for the given index.
190 // When setting a composite type, it is unspecified whether the set
191 // value aliases the source's memory in any way.
192 //
193 // Set is a mutating operation and unsafe for concurrent use.
194 Set(int, Value)
195
196 // Append appends the provided value to the end of the list.
197 // When appending a composite type, it is unspecified whether the appended
198 // value aliases the source's memory in any way.
199 //
200 // Append is a mutating operation and unsafe for concurrent use.
201 Append(Value)
202
203 // AppendMutable appends a new, empty, mutable message value to the end
204 // of the list and returns it.
205 // It panics if the list does not contain a message type.
206 AppendMutable() Value
207
208 // Truncate truncates the list to a smaller length.
209 //
210 // Truncate is a mutating operation and unsafe for concurrent use.
211 Truncate(int)
212
213 // NewElement returns a new value for a list element.
214 // For enums, this returns the first enum value.
215 // For other scalars, this returns the zero value.
216 // For messages, this returns a new, empty, mutable value.
217 NewElement() Value
218
219 // IsValid reports whether the list is valid.
220 //
221 // An invalid list is an empty, read-only value.
222 //
223 // Validity is not part of the protobuf data model, and may not
224 // be preserved in marshaling or other operations.
225 IsValid() bool
226}
227
228// Map is an unordered, associative map.
229// The entry [MapKey] type is determined by [FieldDescriptor.MapKey].Kind.

Callers 26

testFieldListFunction · 0.95
testFieldListFunction · 0.95
testFieldListFunction · 0.95
setListFunction · 0.65
unmarshalListMethod · 0.65
unmarshalFieldMaskMethod · 0.65
unmarshalListMethod · 0.65
NewFunction · 0.65
unmarshalListMethod · 0.65
mergeListMethod · 0.65
testPopulateMessageFunction · 0.65
AppendMutableMethod · 0.65

Implementers 8

emptyListtypes/dynamicpb/dynamic.go
dynamicListtypes/dynamicpb/dynamic.go
listReflectinternal/impl/convert_list.go
testListinternal/reflection_test/reflection_te
zeroListinternal/reflection_test/reflection_te
shadowListinternal/reflection_test/reflection_te
reflectListtesting/protocmp/reflect.go
testListtesting/prototest/message.go

Calls

no outgoing calls

Tested by

no test coverage detected