Not only Dame Time but also Go Time

I wanted to publish this article during the early days of the NBA Playoffs, when Damian Lillard was balling. Although it’s a bit too late now, he still deserves a big shout out.

In this post we will review and deploy a golang application that follows the clean architecture principles.
Source code can be found here.


Most of us have probably worked on large projects where parts of the code were so difficult to extend, understand and sometimes even maintain.
Sometimes the mess is so serious, that nobody wants to touch that part/component/system and before you know it, you’re stuck with a system that needs some serious refactoring, or even worse, needs to be completely re-written.

The size of the team only matters…

In this post I am going to cover some common cases and incidents that you are likely to experience when using goroutines and how to deal with them.

Table of contents:

1. Waiting for the goroutines
2. Deadlocks
3. Getting unexpected results
4. Race conditions


First, what’s a goroutine?

Golang is concurrent by nature.
To achieve concurrency, Go uses goroutines — functions or methods that run concurrently with other functions or methods.
Yes, even Golang’s main function is a goroutine!

goroutines can be viewed as lightweight threads, but unlike threads, they are not managed by the operating system, but by Golang’s runtime.


Around 9 months ago I started making the transition from Python to Golang, mainly due to the technology stack used in my company.

One difficult spot I found was mocking AWS services.
In this article I am going to demonstrate how to mock AWS services using Golang.

Motivation (Why do we even need to mock)?

In the previous article, I demonstrated how to build, deploy and test a Lambda with Python and Pytest.

During an application development life cycle we want to make sure that the code we write is working properly, and that we’re not breaking other components while adding new ones. …

Update 07.09.2020: Added an AWS DynamoDB.

In this article we will build, test and deploy an example lambda using SAM, Python3 and Pytest, while maintaining maximum code coverage, development velocity and simplicity.

AWS provides an open source framework for building serverless applications — Serverless Application Model.

SAM allows you to easily deploy lambdas on AWS, simplifies the process and saves you lots of time and headache with zipping, installing dependencies and etc.

pip packages: pip install pytest jq yq responses requests moto
An S3 bucket(s) to store the lambda artifacts

Why SAM?

While there are…

Reshef Sharvit

Backend 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