How it works...

Once the command has executed successfully, hello.pb.go will be created inside the proto directory, which will look like as shown in the following screenshot:

Let’s understand the .proto file we have written:

  • syntax = "proto3";: Here we specify that we are using proto3 syntax, which makes the compiler understand that the protocol buffer has to be compiled with version 3. If we don't specify the syntax explicitly then the compiler assumes we are using proto2.
  • service Say { rpc Hello(Request) returns (Response) {} }: Here we defined an RPC service with the name Say and a Hello method that takes Request and returns a Response ...

Get Go Web Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.