Meet Our Team at  KubeCon Europe!
The VictoriaMetrics Observability News And Blogs
Read Our Technical & Business Content on Monitoring Solutions & Time Series Databases
Author:

Phuong Le

Inside Go's Unique Package: String Interning Simplified

by Phuong Le on Sep 30, 2024

When you’ve got several identical values in your code, you only store one copy. Instead of having several copies of the same thing, they all just point to this one version, which is a lot more efficient. It’s a process often called ‘interning’ in programming circles.

Read

Go Singleflight Melts in Your Code, Not in Your DB

by Phuong Le on Sep 20, 2024

What singleflight does is ensure that only one of those goroutines actually runs the operation, like getting the data from the database. It allows only one ‘in-flight’ (ongoing) operation for the same piece of data (known as a ‘key’) at any given moment.

Read

Go sync.Cond, the Most Overlooked Sync Mechanism

by Phuong Le on Sep 13, 2024

In Go, sync.Cond is a synchronization primitive, though it’s not as commonly used as its siblings like sync.Mutex or sync.WaitGroup. That said, as a Go engineer, you don’t really want to find yourself reading through code that uses sync.Cond and not have a clue what’s going on.

Read

Go sync.WaitGroup and The Alignment Problem

by Phuong Le on Sep 6, 2024

When we’re spinning off many goroutines to do their thing, we want to keep track of them so that the main goroutine doesn’t just finish up and exit before everyone else is done. That’s where the WaitGroup comes in. Each time one of our goroutines wraps up its task, it lets the WaitGroup know.

Read

Slices in Go: Grow Big or Go Home

by Phuong Le on Aug 30, 2024
Read

Go sync.Pool and the Mechanics Behind It

by Phuong Le on Aug 23, 2024
Read

Go Maps Explained: How Key-Value Pairs Are Actually Stored

by Phuong Le on Aug 16, 2024

Map is a built-in type that acts as a key-value storage. Unlike arrays where you’re stuck with keys as increasing indices like 0, 1, 2, and so on, with maps, the key can be any comparable type.

Read

Go sync.Mutex: Normal and Starvation Mode

by Phuong Le on Aug 9, 2024

Mutex in Go has two main flows: Lock and Unlock and 2 modes: Normal and Starvation Mode. The state field of mutex is a 32-bit integer that represents the current state, it’s divided into multiple bits that encode various pieces of information about the mutex.

Read

How Go Arrays Work and Get Tricky with For-Range

by Phuong Le on Aug 2, 2024

As always, we’ll start with the basics and then dig a bit deeper. Don’t worry, Go arrays get pretty interesting when you look at them from different angles. Arrays in Go are a lot like those in other programming languages. They’ve got a fixed size and store elements of the same type in contiguous memory locations.

Read

Golang Defer: From Basic To Traps

by Phuong Le on Jul 26, 2024

The defer statement actually has 3 types: open-coded defer, heap-allocated defer, and stack-allocated. Each one has different performance and different scenarios where they’re best used, which is good to know if you want to optimize performance.

Read

Watch Your Monitoring SkyRocket With VictoriaMetrics!