TL;DR: prevailing “secondary source” wisdom (ie: blog posts) about json.Decoder don't demonstrate the proper way to use it.

This post is a follow up to my (kinda lengthy) deep dive into what I thought was a bug in golang’s json.Decoder pkg.

Instead, I realized that generally speaking, json.Decoder can be misunderstood - which may lead to unintended consequences. In this post, I will demonstrate a safer pattern that ought to be used instead of the prevailing wisdom.

Googling: “json.decoder example golang”

I ran a few google searches queries using some permutation of the following:

json.decoder example golang

The results were your standard mix of…


TL;DR: use $(eval ARGS=${ARGS} [some additional arg]) within a make target to build custom argument sequences for commands wrapped by make targets - like make test

I expound further on the usecase and methodology below 👇

I like to wrap common tasks, such as running unit tests, around a make target.

This way, I can minimize the length of the command I need to run (ie: make test vs go test ./... -race -coverprofile=c.out)

However, as a project grows, it becomes necessary or just preferable to support a variety of permutations of the above.

(Note: I am not advocating that…


TL; DR: When integrating golang code coverage with Code Climate, be sure to set the --prefix arg (set it to your pkg github prefix, ie: "github.com/mottaquikarim/esquerydsl") in the after-build stage in order for your src code to be recognized by the test reporter.

If ^^ that didn’t make sense, read on below for the full background 👍

I’ve recently published a golang pkg, called esquerydsl, which facillitates safe construction of elasticsearch queries in golang.

In order to ensure future stability, I wanted to integrate Code Climate for tracking maintainability and test coverage.

I’ve used CC before on python projects but…


TL; DR: introducing a golang package for creating elasticsearch query DSL JSON strings: find it here!

Photo by Ferenc Almasi on Unsplash

The Why

If you’ve used elasticsearch with golang, then you’ve probably used the official elasticsearch go client.

The es go client is exhaustive and generally, pretty great. However, it can be a bit…scary when having to deal with constructing search queries using the elasticsearch query dsl.

Take for instance the following (from here in the docs):

Using strings

In my experience, the simplest/fastest way to construct this json string is with…well, a string:

If we need to inject variable values, we just use fmt.Sprintf and move…


In a previous article, we reasoned about a method for somewhat quickly computing the squares of numbers.

In this article, we will try to come up with a method for cubing numbers ending in — 5.

TL;DR — for any whole number n:

(10n + 5)^3 = concatenate(0.5*n(n+1)(2n+1), 250n + 125)

To begin, let us examine a few results:

15^3 = 3375
25^3 = 15625
35^3 = 42875
45^3 = 91125
55^3 = 166375
65^3 = 274625
75^3 = 421875
85^3 = 614125
...

Notice how there’s already a pattern: the endings 375, 625, 875, and 125 repeat for all…


In a previous article, we explored a trick for squaring numbers that end in — 5 really quickly.

Here, we will attempt to extrapolate our findings to the general case, ie: squaring all numbers.

Let’s begin by considering 26 * 26.

26 * 26 = 
(20 + 6)(20 + 6) =
20*20 + 20*6 + 6*20 + 6*6 =
20(20 + 6 + 6) + 6*6 =
20(20 + 12) + 6*6 =

We started by attempting the approach that worked for us in our approach for squaring numbers ending in — 5 quickly. …


So here’s a neat trick. What’s a quick way to square numbers that end in — 5 in your head?

For example, what is 25* 25? (Plug into a calculator real quick). We expect our trick to give us: 625.

Now, let’s explore how our “trick” (more of an algorithm, really) works:

First, we take the number in the tens place.

In this case — 2.

Add 1 to the number in the tens place.

So 2+1, which is 3.

Multiply our first number (2) by the second number (3).

Ok, so 2 * 3 = 6.

Great! Almost there, hold 6 in the back of your head for a bit.

Take the number in the ones place (5) and square it.

5^2 = 5 * 5 = 25

Take the (6) from our previous computation and concatenate with (25). Result will be (625).

In computer science, concatenate means to smoosh together. For example…


This auto-generated post chronicles Samantha and Taqqui’s adventures in Kennebunkport, ME by aggregating photos and comments shared by Taq on a daily basis for the entire duration of their trip.

Places We Visited

Here is a map of all the destinations we visited today. (Source)

Map Key:

(Click on the place names to explore on an interactive Google maps)

Photos Taken


This auto-generated post chronicles Samantha and Taqqui’s adventures in Kennebunkport, ME by aggregating photos and comments shared by Taq on a daily basis for the entire duration of their trip.

Whoopie pie is pretty popular in Maine. (Source)


This auto-generated post chronicles Samantha and Taqqui’s adventures in Kennebunkport, ME by aggregating photos and comments shared by Taq on a daily basis for the entire duration of their trip.

Places We Visited

Here is a map of all the destinations we visited today. (Source)

Map Key:

  • A: Rococo Artisan Ice Cream
  • B: Kennebunkport Bicycle Company
  • C: Kennebunk Gallery Motel and Cottages
  • D: The Clam Shack
  • E: Wells Regional Transportation Center
  • F: Boston Common Coffee Company
  • G: Amtrak NY Penn Station

Photos Taken

Taq Karim

Engineering @Oracle , Faculty @GA + @BaruchCollege . Prior: @PlaceExchange , @sharehoney , @RubensteinTech , @joinpursuit , @TheKingsCollege

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