Generated code for protobufs
One practical use case for generating code in Go is generating protocol buffers using gRPC. Protocol buffers are a new method that is used to serialize structured data. It's commonly used to pass data between services in distributed systems, as it tends to be much more efficient than its JSON or XML counterparts. Protocol buffers are also extensible across multiple languages on multiple platforms. They come with a structured data definition; once you have your data structured, source code is generated that can be read from, and written to, data sources.
First, we need to grab the latest version of the protocol buffers: https://github.com/protocolbuffers/protobuf/releases.
At the time of writing, the stable version ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access