Hello Gophers, Most of us who tried unit testing must have stuck at external dependencies. That external dependency is maybe of message broker, database, external service APIs, or any other functionality. We wish to decouple our code from the external dependencies and test just what is ours. This post tries to address this scenario.

Let's say we have this piece of code consuming external package “external”

And our External dependency code looks something like this.

As you must have guessed, we would like to Mock this dependency function. Golang’s Interface facilitates exactly that. Let me show you how?


An Index is an additional structure that is derived from the primary data in the database. Considering this many databases allow to add indexes to the database that does not affect the contents of the databases, It only affects the performance of the query.

Now since indexes are the additional structure, maintaining them causes overhead. Indexes are known to increase the cost of writes. Lets dig in how?

Consider the world's easiest database, a log file. Don’t confuse the log files which refer to the Application Logs, where an application output text that describer’s what’s happening. …


There are two types of programming Language paradigm

1. Imperative Language

An imperative language tells the computer to perform certain operations in a certain order. For example Lets assume that we have CSV file of data about College. In order to find all the students from “Computer Science” department we will write program as follow.

List result;for(all the lines in CSV){
if(department is equal to "computer science"){
add to the result;
}
}

We can see ourselves stepping through the code line by line, evaluating conditions, updating variables, and deciding whether to go around the loop one more time.

Most of the…


Everything on the Linux/UNIX system is considered to be a file. With this assumption, Does that mean processes are also files? Yes, they are. You can find everything about processes in the /proc directory on Linux/Unix system.

In fact, there is a complete directory dedicated to a process in /proc. If we "ls" to the /proc, we are presented with a list of numerical directories. The number here is nothing but the Process ID's. If we ls into those, we can find everything about a process. Like a link to the executable of this process, the last CPU used, memory held…


As a professional, it's our duty to write Clean code. It is not a mandate, not a charter, not a pledge but a given thing. It's a stepping stone on the journey of software craftsmanship. Every developer must adhere to this paradigm.

While writing code I have these two motivations.

  1. The code should be aesthetic to the eyes. (Feeding to my OCD). My colleagues should be able to understand the code, they should never call me on my day off.
  2. The code should be easier to write unit tests for. …

A constant pain-point for a developer to meet with the business need in a complex product is to streamline the requirements. Freezing requirements make the developer’s life easy but this goes against the Agile Methodology. As the second principle out of the 12 agile principle says.

Welcome changing requirement, even late in development. Agile processes harness change for the customer’s competitive advantage.

So how do we take the best of both of this world and make the developers as well as PM org’s life easy and happy? (As if the executives will let us. ) and being agile.

Let's recreate…

Shailesh Suryawanshi

A wizard with no Magic.

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