Credits to alexander ehrenhöfer (

Several moments ago, I was wondering if we have multi cron job that are running same binaries, but we need to make sure that each job / task process is being ran only by one instance, is there a way to achieve that. I know this is weird, why do we bother having multiple binaries? just create one for the cron job! It is right though, but wondering about the problem, I was triggered if we could do it with MYSQL, and it can.

Given Problem Statement and Solution

To sum up, here are the challenge

Usually i wrote something about software engineering / programming, but this one will be different. I would like to share a thing that happened in 2020 that enlightened and hit me differently. This one will be mostly about how you should care about your health and take good care of it while you can.

Credits to Jamie Street (

Prolog / Background

Last year, in the Q3 of 2020 my father was sick. It was started with some symptoms of limp, sometimes hard to breath, lack of appetite, nausea, and others uncomfortable things (pardon me for not so good english in describing a disease related topic). The point…

Credits to Greyson Joralemon (

There are several “fun things” that you need to know, this might help you to prevent going in pitfalls when writing golang program. These includes:

  1. Slice and Map are reference type
  2. Child Go routine and Parent
  3. Don’t use basic type string / int / others for context key

Interface Holding Nil Value, But Not Nil

Look at the simple code below

var i interface{}
var pint *int
i = pint
fmt.Println(pint, pint == nil, i, i == nil)

It will print the output of

<nil> true <nil> false

While pint variable is a nil (a pointer to an int…

Credits to Łukasz Rawa (

Recently I created a simple Golang automatic “retrier” that will do automatic retry on our desired struct method with configurable maximum attempt.

Summarizing the automatic retrier flow there are several things that we need to implement:

  1. Then we can create a new retrier function with object based on the previous struct, configured with our desired maximum attempt and logger if needed (by New command)
  2. Invoke the action to do the execution and automatic retry upon failing the Exec method (by Start() command)


Credits to Tamara Gak (

Continuing our basic Golang unit testing example, we are going to continue on another step of simple function mocking for unit testing in Go. In here We’re only going cover this two “kind” of function:

  1. Function imported (from library or stuff) outside of your project

Therefore, we’re not going to “mock” method which belongs to a struct right now. You might ask, why do I need to mock a function? Can we just call the function as is? …

Credits to NeONBRAND (

In a nutshell basically you need to test the code you write to ensure you’re doing it right. If you have a function that add two numbers, you will expect the result to be sum of those two numbers, by writing the unit test, you make sure that when the function is being ran with the given parameters, it will return the correct / expected result or behavior.

This writing will cover up only the basic of golang unit testing with some example and explanation, more advance and complex unit testing / even mocking a function will be covered in…

Credits to Markus Spiske at

Have you ever heard of closure before?

Ups different closure…

So, What is Closure in Golang?

By Tour of Go definition, closure can be described as

Go functions may be closures. A closure is a function value that references variables from outside its body. The function may access and assign to the referenced variables; in this sense the function is “bound” to the variables.

I modified the code a bit from the Tour of Go example:

We’re going to create a simple API doc with the help of library. It supports several golang framework such as gin, echo, fiber, flamingo, net/http, etc. In a nutshell you need to install it first (for generating via CLI), write some comments metadata in your API / handler / controller, generate and done!

Image example from the github documentation

Creating the API

First let us create some simple API using gin framework. We’re initiating an API group of “/api/v1/user” in which consists of two endpoint

  1. Post and create new user based on JSON body sent by request

Credits to Markus Spiske (

If you’re having a public endpoint, securing it is a must and cannot be considered as nice to have. I would like to share several ways to secure your API Endpoint (Golang will be used for this example), and in this writing we won’t be discussing about any encryption related topic for simplicity. There are some ways to secure your API endpoint using these methods:

  1. Consider limiting your exposed parameter to prevent resource abuse
  2. Only allow trusted source
  3. Implement rate limiter

1.) Sanitize Input

Image credits to CHUTTERSNAP (

What on earth is this writting? This tutorial will demonstrate a simple golang API for uploading file to Google Cloud Storage. GCS (Google Cloud Storage) can be used for uploading your image, files, assets, basically any file with the benefits of

Aditya Rama

Fellow Software Engineer

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