New Opaque API for Go and removing a reflection-related function in v30

85 views
Skip to first unread message

David Castro

unread,
Dec 20, 2024, 12:06:57 PM12/20/24
to Protocol Buffers
New Opaque API for Go

Back in March 2020, we released the google.golang.org/protobuf module, a major overhaul of the Go Protobuf API. This package introduced first-class support for reflection, a dynamicpb implementation and the protocmp package for easier testing.

That release introduced a new protobuf module with a new API. Today, we are releasing an additional API for generated code, meaning the Go code in the .pb.go files created by the protocol compiler (protoc). The blog post at https://go.dev/blog/protobuf-opaque explains our motivation for creating a new API and shows you how to use it in your projects.

To be clear: We are not removing anything. We will continue to support the existing API for generated code, just like we still support the older protobuf module (by wrapping the google.golang.org/protobuf implementation). Go is committed to backwards compatibility and this applies to Go Protobuf, too!

Another change in v30

In v30.x, we are removing the following reflection-related function: MutableRepeatedFieldRef<T>::Reserve().

An upcoming performance improvement in RepeatedPtrField is incompatible with this API. The improvement is projected to accelerate repeated access to the elements of RepeatedPtrField, in particular and especially sequential access.

Reply all
Reply to author
Forward
0 new messages