Remove List from KnownFields, UnknownFields, ExtensionFieldTypes, and Map. Rationale: * Each of those interfaces already have a Range method, which provides a superset of the functionality of List. Furthermore, Range is more expressive as it allows you to terminate iteration and provides both keys and values. * List must always allocate a slice and populates it. * Range is allocation free in some cases. For example, if you simply wanted to iterate over all the populated fields to clear them, there is no need for a closure, so a static version of the function can be directly referenced (i.e., there is no need to create a stub function header that references the closed-over variables). * In the cases where a closure is needed, the allocation cost is O(1) since there are a finite number of variables being closed over. * In highly performance sensitive cases, the closured function could close over a struct, such that the function and struct are stored in a sync.Pool when not in use. For example: type MapLister struct { Entries []struct{K MapKey; V Value} f func(MapKey, Value) true } func (m *MapLister) Ranger() func(MapKey, Value) bool { if m.f != nil { m.f = func(k MapKey, v Value) bool { m.Entries = append(m.Entries, ...) return true } } m.Entries = m.Entries[:0] return m.f } The main benefit of List is the ease of use: for _, num := range knownFields.List() { ... } as opposed to: knownFields.Range(func(n FieldNumber, v Value) bool { ... return true }) However, this is a marginal benefit. Thus, remove List as it mostly inferior to Range. Change-Id: I25586c6ea07a4706072ba06b1cf25cb6efb5e8a7 Reviewed-on: https://go-review.googlesource.com/c/142888 Reviewed-by: Damien Neil <dneil@google.com>
Next Generation Go Protocol Buffers
WARNING: This repository is in active development. There are no guarantees about API stability. Breaking changes will occur until a stable release is made and announced.
This repository is for the development of the next major Go implementation of protocol buffers. This library makes breaking API changes relative to the existing Go protobuf library. Of particular note, this API aims to make protobuf reflection a first-class feature of the API and implements the protobuf ecosystem in terms of reflection.
Design Documents
List of relevant design documents:
Contributing
We appreciate community contributions. See CONTRIBUTING.md.
Reporting Issues
Issues regarding the new API can be filed at
github.com/golang/protobuf.
Please use a APIv2:
prefix in the title to make it clear that
the issue is regarding the new API work.