How to implement a basic service discovery using Golang

With the breakthrough of microservices in today’s world, the increasing number of users, requests, and demands have made this job very difficult. In the cloud-based microservices era, our services are constantly changing due to all kinds of different situations such as autoscaling, failures, and upgrades. As a result of these changes, they continuously get their new IPs.

This is where service discovery enters the microservices scene. We need some system, written in golang, that will keep an eye on all services at all times and keep track of which service is deployed on which IP/port combination at any given time, so that the clients of microservices can be seamlessly routed accordingly.

This article describes a solution written in Golang.