Understanding Inner workings of the Golang Channels

A goroutine is a lightweight user-space thread, which is managed by the Go runtime. It executes tasks concurrently, potentially in parallel.

A channel is for communication between goroutines.

In this post, we will delve into the inner workings of the channel and its send/ receive operations.

Making Buffered channels

Let’s first create a…

Assume we have a list of timestamps and flags to indicate if the record is an anomaly or not (1 for abnormality, 0 for normal).

timestamp            is_anomaly
2021-07-05T00:00:32 False
2021-07-05T00:01:32 False
2021-07-05T00:01:45 True
2021-07-05T00:02:01 False
2021-07-05T00:05:12 False
2021-07-05T00:05:24 True
2021-07-05T00:05:37 True
2021-07-05T00:08:11 True
2021-07-05T00:09:12 False
2021-07-05T00:10:15 False
2021-07-05T00:11:23 False

We…

This tutorial will learn how to check the replica set status in MongoDB.

MongoDB is a NoSQL document-oriented database that makes it easy to get started with document-oriented databases.

The replica set status of MongoDB will tell you the health of your replica set, how many replicas are in each member, the size of the replica set, and how many replica set members…

An example to understand Go channels

Here is a classic interview question related to Go Goroutines. It is an excellent example to understand channels and Goroutines.

Problem Statement

Please use two Goroutines to print the sequence alternately; one prints numbers, and the other prints letters. The final result is as follows:

12AB34CD56EF78GH910IJ1112KL1314MN1516OP1718QR1920ST2122UV2324WX2526YZ2728

Solution

The solution is simple. …

Jerry An

Developer in China, AI and machine learning enthusiast. To support me join Medium: https://jerryan.medium.com/membership

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