Server boilerplate
Our build system is ready. We can now focus on the code. But before going into that, let us define what we want. In this section, we want to build a template for the gRPC server that we can reuse for later chapters and even later projects outside of the book. To do that, there are a few things that we want to avoid:
- Implementation details such as service implementation
- Specific connection options
- Setting an IP address as constant
We can solve these by not caring about the generated code anymore. It was just for testing our build system. Then, we will default to an insecure connection for testing. Finally, we will take the IP address as an argument for our program.
Let us do that step by step:
- We are first going to need to add the gRPC dependency to
server/go.mod
. So, in theserver
directory, we can type the following command:$ go get google.golang.org/grpc
- Then, we are going to take the first argument passed to the program and...