In December 2024, Google released an additional API for generated code in Go Protobuf, creating a new Opaque API that separates the memory layout to improve efficiency and performance. The Opaque API hides struct fields and provides accessor methods for getting, setting, or clearing fields, reducing memory usage and allocations. Motivations for the new API include reducing pointer comparison mistakes, accidental sharing mistakes, and improving memory layout for better performance. Lazy decoding is also enabled with the Opaque API, offering significant performance improvements for specific workloads. Migration to the Opaque API is recommended for new development, with the Hybrid API available for maintaining existing code compatibility.
https://go.dev/blog/protobuf-opaque