A Go service that incorporates multiple HTTP REST servers using just the built in standard library.


Most software engineers are likely to need to build HTTP REST services in their day job, or use them to explore ideas in their personal projects. We are likely to pick off the shelf libraries that take care of most of the boiler plate for us — for example where I work I only need to implement the endpoints and business logic, everything else is prepackaged, tested and maintained by another team. …

A full walkthrough of how I built a pipeline that deploys an app from a monorepo to GKE


Monorepos are great when working with lots of repos that rely on each other in some way or another. They solve a lot of problems that microservices bring along with them, such as

  1. allowing sharing of code through libraries across all services, and making it a lot easier to upgrade or change libraries across the whole repo — try upgrading your logging library across all your services with polyrepos and see how laborious it can be;
  2. making it easier to refactor code…

A walkthrough of Embedding in go version 1.14

Embedding¹ is a clever way of extending/composing many types into a single type. It represents the O² part of SOLID³ principles — Open closed principle; open to extension, closed for manipulation. What this means is that we can easily extend a type so that it does the original thing, as well as something else without having to amend the original implementation.

Sample Code for this Post

All running sample code can be found here — https://github.com/ankur22/embedding

Struct Embedding

In the example below, I’ve declared a logger and a checker, and each implement a function do and validate respectively. I’ve…

Useful notes on how to create iptables rules in an Ubuntu VM

The main reason for creating a VM was to be able to perform a GET request against the sinkhole URL that was highlighted in an article by Wired magazine on Marcus Hutchins. I’m pretty sure i could have safely done it via my laptop without the VM, but it also sounded like a fun little afternoon project to work with iptables.

NOTE: I’m not a professional white hacker/pen tester, the following are just notes that I’ve taken while creating a VM to perform outgoing HTTP requests and to disallow all connections coming in. …

Lessons from working with goroutines, channels, contexts, timers, waitgroups, and errgroups. Also includes a couple of simple things to make your code more efficient.


You may one day find yourself needing to perform an ETL job from a file to a remote database. Go is a perfect tool to perform this sort of ETL thanks to go’s ability to easily work with threads.

It’s quite a convoluted task to get multiple goroutines to coordinate the read from the same file — the most robust solution might involve using a consensus algorithm which feels like it’s over engineering the solution. …

TL;DR — Test the Behaviour not the Implementation

The key take away is when we work with TDD:

  1. Write failing tests
  2. Write tests against the observable behaviours, which in go is the package’s public APIs
  3. Do not write tests for the implementation which would start failing if we refactored the implementation
  4. Write the implementation as quickly as possible, it can be a C&P from StackOverflow! Just get the test to pass asap!
  5. REFACTOR! Deduplicate code; use design patterns; remove code smells; make it maintainable; don’t write any new tests.

The final step is important and can only be achieved if we only test the behaviour of the public…

The days were normal, no one could tell the difference during the day. The nights were still dark. Scientists and researchers had seen it coming but could only theorise the reason. That’s what my grand parents told me.

Now there’s no night or day, just light everywhere. It’s still warmer during the day though. Radiation will eventually kill everything on this planet, well, maybe not the beetles or super bugs that may mutate into something else.

There’s no where to run. Our space ships can’t travel faster than light, even if they could which direction would they go? A sky full of infinite stars. It’s peaceful though.

Camino del Santiago — What is it, where is it, can i eat it?! Many questions queued up in my mind when my girlfriend (Jen) mentioned that she was planning on doing the Camino with her friend. Unfortunately her friend was unable to go, but the backup (me) was available.

To the non religious person it’s a long walk from a given starting point to Santiago. To the religious person (particularly Catholic Christians) it’s a pilgrimage.

I’m neither Christian or particularly religious. I sometimes go to the temple (my family is Hindu), and a feeling of serenity does comes over…

Ankur Agarwal

On an adventure

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store