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.
Let’s first create a buffered channel for the following explanation.
ch := make(chan int, 3)
The statement above creates a buffered channel capable of holding up to 3 values of type
Under the hood, the function
make allocates an
hchan struct on the heap and returns a pointer to it.
Here are some…
Despite having seen all these concepts more than a thousand times, I’m still getting confused sometimes. Is there a good way to think about all these concepts so that they start making sense?
In this post, I will focus on how to remember them. If you’re not familiar with them, please read the following posts first.
A confusion matrix is a table used to evaluate the performance of a classification model. It summarizes the count combinations of every predicted and actual class.
Let’s understand this concept in a simple example. Below…
Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs and geospatial indexes with radius queries.
Redis is the world’s most popular in-memory data structure server. In order to make good use of it, we need to understand its basic data structures first.
The Redis String type is the simplest type of value you can associate with a Redis key. …
Data preparation is an important step before doing data analysis and reporting. As a data engineer, It usually occupied 80% of the development time.
Yet, it is only a series of processes of exploring, cleaning, and modifying raw data.
Google Cloud Dataprep makes this data preparation easy, fast, and interesting.
Google Cloud Dataprep is a data service for exploring, cleaning, and preparing structured and unstructured data.
It has the following capabilities:
Go is an awesome programming language with high performance, expressiveness, and readability.
In this post, I will use a web crawler example to show its super-powerful concurrency ability.
Some basic abilities are needed for a web crawler in Go.
Here is the code:
1️⃣ Here we want to take advantage of all the cores on the machine to achieve high concurrency.
2️⃣ Here we use a ticker containing a channel that will send the time on the channel after each tick.
This post is intended for anyone who wants to get a whole picture of some google cloud services for data engineers and data analysts.
Google Spreadsheet lets you organize data and calculations online.
Google Data Studio is an online tool for converting data into customizable informative reports and dashboards.
The Big query…
When talking about string, bytes, and runes, many entry-level Golang developers feel confused. In this post, I’d like to give some explanations from an application developer standpoint.
If you prefer thorough explanations from Rob Pike, who is the partner invertor of Go language. Please be free to have a pause here and read the following post.
A byte in Go is an unsigned 8-bit integer. That means it has a limit of 0–255 in the numerical range.
type byte = uint8
According to Go documentation, Byte is an alias for uint8 and is the same as uint8 in all ways…
Have you struggled to decide which programming language is worth learning in the next 10 years?
In this post, I will list 5 reasons to tell why you should start to learn Go Programming Language.
In Go, the data types divide into four categories which are as follows:
In this post, we will discuss four composite types: arrays, slices, and maps, structs.
As we start to scale an application horizontally, we may run into a problem that requires distributed locking.
In this post, I will show you how to implement a distributed lock step by step based on Redis and python.
Building a mostly correct lock in Redis is easy. It consisted of three steps:
def acquire_lock(conn, lock_name, acquire_timeout=10): identifier = str(uuid.uuid4())
end = time.time() + acquire_timeout
while time.time() < end:
if conn.setnx("lock:"+lock_name, identifier)