Why Test Driven Development ?

Before saying anything, I would like to answer the question Why? Why TDD at first place? It’s a very BASIC question, but it’s a general observation that people who often ask WHY often tends to stay in the right direction rather than going down the rabbit hole without a sense of purpose at all. Hence, whatever your job may be, whether it’s business, programming, following the rabbit to the hole or what not, never be afraid to ask WHY. Now you’re wondering why I am talking about the rabbits when I came here to talk…

In my few years of using Golang, I’ve come across several discussions involving the use of interfaces. The arguments range from:

Why are we not defining interfaces with the type definition like in typical static languages like C++, Java etc ?

Should this package export interface in combination with the exposed type implementing the interface?

Should this function return an interface rather than the concrete type?

Let’s try to address these questions one by one.

Why are we not defining interfaces with the type definition like in typical static languages like C++, Java etc ?

In languages like C++, Java, one needs to specify that a type implements an interface like in the code given below:

In such languages…

In this technical era, everyone has at least once in their life thought about creating a website and showcasing it to the world. Is it your pet project? A business idea you want to test? Or just a skill you you want to acquire for future use? A lot of non technical people use Wordpress, Wix or other providers to host their content, but if you need your own domain, you would have to pay for it.

Below is the step by step guide of how we hosted our website from scratch.
Let’s start.

Get a domain

First step is to buy a…

Load testing.

Now that we have learnt about the difference between Siege and Apache JMeter in the previous article, it’s time to talk about running basic HTTP api load tests with JMeter.

JMeter is a pure Java application and should run correctly on any system that has a compatible Java implementation.

One can download and install apache JMeter from here.

Open it and let’s get started. You’ll see an empty Test Plan as below.

Load Testing APIs

Why load test?

Imagine a scenario where people are waiting at the airport to do the COVID-19 test before they could get home. And the only way they can register for that test is by using your app. Now imagine their frustration if your app fails to load, or some of your apis fail because they are not performant enough.

Had you had load tested your services, you would have an idea how much load your services could handle and what steps you would need to take in order to enable your services to handle bigger load while optimising the cost of resources…

Photo by Markus Spiske on Unsplash

While on production, it is important to run your containers as non root users to avoid any security vulnerabilities.

The rationale

From security perspective, running a process on container as root user is as bad as running a process as root on host machine itself. If a user manages to break out of an application running as root in a container, he may be able to gain access to the host with the same root user. More information about this can be found at this interesting blog post.


We will be using helm for deploying our nginx application on kubernetes.

Create helm charts

The first…

Photo by frank mckenna on Unsplash

Docker, as we all know, is the most popular tool for creating containerised applications these days. The more I use it, the more I fall in love with the concept. As easy as it is for even the beginners to write a Dockerfile, some small things can help you to optimise your images to a large extent. Following are few very useful tips which I have found helpful personally.

Understand Docker Layering.

The key point to keep in mind is that newer versions of Docker creates layers on RUN, ADD and COPY commands. So try to minimise the layers by keeping these three…

Photo by Louis Reed on Unsplash

Imagine you have a Raspberry Pi and a lazy ass, or you just don’t have a monitor and keyboard to connect with your Raspberry Pi, but you still want to be able to work with it, or you just want to use it as all things embedded (like a robot), this article is for you. If you’re fond of command line, you can run your Raspberry Pi in headless mode, i.e. without a monitor or keyboard.

Other than Raspberry Pi 3, you will need a power source, SD Card and a computer( with MacOS is our case ).

First things…

Go offers scalable and robust mechanism for creating API servers. As most of APIs talk to some database, on a scaled infrastructure receiving a lot of requests per second, it is important to shutdown gracefully in order to prevent goroutine leaks. This means closing two things in our case.

HTTP Server and DB connection.

Go net/http package offers Shutdown function to gracefully shutdown your http server. https://godoc.org/net/http#Server.Shutdown.

Go database/sql package offers Close function to gracefully close the connection to sql. https://godoc.org/database/sql#DB.Close

1) Create a minimal HTTP API service using a Database.

2) Change your server function “srv.ListenAndServe()” to run in a goroutine.

go func() {    panic(srv.ListenAndServe())}()

This is done to ensure that main will not exit when srv.ListenAndServe() returns…

Email verification is one of the basic things most websites use to make sure that the users that registers with them are real. The user is normally asked to click a link sent on his email. When the user clicks the link, the server recognises the user based on the information passed in link and marks it as verified. There are many ways to do so, two major of them being:

1. Generate a unique code specific to user and save it in your database corresponding to that user. Send the code in the email link sent to user. When…

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