0PricingLogin
Go Academy · Lesson

Protocol Buffers and .proto Files

Message types, services, and protoc codegen

What are Protocol Buffers?

Protocol Buffers (protobuf) is a language-neutral, binary serialization format developed by Google. It is smaller and faster than JSON and is the canonical wire format for gRPC.

.proto file syntax

Define messages and services in a .proto file:

syntax = "proto3";
package user;
option go_package = "github.com/example/user/pb";

message User {
    int64 id   = 1;
    string name = 2;
    string email = 3;
}

service UserService {
    rpc GetUser (GetUserRequest) returns (User);
}
message GetUserRequest { int64 id = 1; }

All lessons in this course

  1. Protocol Buffers and .proto Files
  2. Implementing a Unary gRPC Service
  3. Server and Client Streaming
  4. gRPC Interceptors and Metadata
← Back to Go Academy