Building a microservice with Go Micro

We will use Go Micro and our encryption logic in utils to write a microservice. A Go microservice should be built in a step-wise manner. To create a service, we need to design a few entities upfront. They are as follows:

  • A protocol buffer file for defining RPC methods of service
  • A handler file that has an actual implementation of methods
  • A server that exposes RPC methods
  • A client that can make RPC requests and get results

We need two system level-tools called protoc and protoc-gen-micro for compiling protocol buffers to Go packages. Let's see the steps for creating an encryption microservice, as follows:

  1. Let's install those compilers using the go get command, as follows:
> go get -u github.com/golang/protobuf/protoc-gen-go ...

Get Hands-On RESTful Web Services with Go - Second Edition 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.