Install the Protocol Buffer Compiler
Distributed Services with Go — by Travis Jeffery (18 / 84)
👈 Why Use Protocol Buffers? | TOC | Define Your Domain Types as Protocol Buffers 👉
The first thing we need to do to get you compiling protobuf is — you guessed it — install the compiler. Go to the Protobuf release page on GitHub[4] and download the relevant release for your computer. If you’re on a Mac, for instance, you’d download protoc-3.9.0-osx-x86_64.zip. You can download and install in your terminal like so:
$ wget https://github.com/protocolbuffers/protobuf/\
releases/download/v3.9.0/protoc-3.9.0-osx-x86_64.zip
$ unzip protoc-3.9.0-osx-x86_64.zip -d /usr/local/protobuf
Here’s what the layout and files in the extracted protobuf directory look like:
❯ tree /usr/local/protobuf
/usr/local/protobuf
├── bin
│ └── protoc
├── include
│ └── google
│ └── protobuf
│ ├── any.proto
│ ├── api.proto
│ ├── compiler
│ │ └── plugin.proto
│ ├── descriptor.proto
│ ├── duration.proto
│ ├── empty.proto
│ ├── field_mask.proto
│ ├── source_context.proto
│ ├── struct.proto
│ ├── timestamp.proto
│ ├── type.proto
│ └── wrappers.proto
└── readme.txt
As you can see, a protobuf installation consists of two directories. The bin directory contains the compiler…