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:

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

Introduction

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.


Introduction:

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.

Introduction:
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.

Prerequisites:
Python3
AWS CLI
SAM CLI
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

Infrastructure 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