Get the latest tech news

Go Protobuf: The New Opaque API


We are adding a new generated code API to Go Protobuf.

Many years ago, your only option to implement a function like redactIP was to reach for Go’s reflect package, which resulted in very tight coupling: you had only the generator output and had to reverse-engineer what the input protobuf message definition might have looked like. The Opaque API makes those possible: Program code uses accessors and does not need to be updated when the memory representation changes, so we could, for example, move rarely set fields into an overflow struct. To opt out of lazy decoding (despite.proto annotations), the protolazy package documentation describes the available opt-outs, which affect either an individual Unmarshal operation or the entire program.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Protobuf

Protobuf

Photo of new opaque api

new opaque api

Related news:

News photo

Show HN: An Elliptic Curve-Based Secure Chat, Written Using Rust and Protobuf

News photo

Parsing protobuf at 2+GB/s: how I learned to love tail calls in C (2021)

News photo

Fivefold Slower Compared to Go? Optimizing Rust's Protobuf Decoding Performance