Building a gRPC Client in Go

In this section, we’ll look at creating a Go client for our RouteGuide service. You can see our complete example client code in grpc-go/examples/route_guide/client/client.go. Creating a stub To call service methods, we first need to create a gRPC channel to communicate with the server. We create this by passing the server address and port number to grpc.Dial() as follows: conn, err := grpc.Dial(*serverAddr) if err != nil { ... } defer conn. [Read More]

Building a gRPC Server in Go

Let’s start off by defining a really simple gRPC server in Go. Once we have a simple server up and running we can set about creating a gRPC client that will be able to interact with it. We will start off by writing the logic within our main function to listen on a port for incoming TCP connections: main.go package main import ( "log" "net" ) func main() { lis, err := net. [Read More]

Cobra - Create CLI in Go

Golang for CLI Go is the perfect language to develop command line applications. Go has a few advantages that really set it apart from other languages: Single binary Very fast execution time, no interpreter needed Go is awesome! Cross platform support Command line based applications are nearly as old as computing itself but this doesn’t mean that they haven’t evolved. Traditional cli applications used flags to manage the different behaviors an application could perform. [Read More]