The VictoriaMetrics Observability Blog
Read Our Technical & Business Content on Monitoring Solutions & Time Series Databases
Tag:

Go

Go I/O Closer, Seeker, WriterTo, and ReaderFrom

by Phuong Le on Oct 18, 2024

Still, we haven’t really covered some other important interfaces, like Closer, Seeker, and a few others. And honestly, if you’re learning Go, you probably don’t want to leave those in the blind spot.

Read

Go I/O Readers, Writers, and Data in Motion

by Phuong Le on Oct 11, 2024

The io.Reader and io.Writer interfaces are probably some of the most common tools. Today, we’re kicking off the I/O series by taking a look at a lot of these readers and writers, and pointing out some common mistakes — like using io.ReadAll in ways that can backfire.

Read

Go sync.Map: The Right Tool for the Right Job

by Phuong Le on Oct 4, 2024

Go’s sync.Map isn’t a magic bullet for all concurrent map needs. It’s got some good tricks up its sleeve, like handling reads without locking, but it’s not always the best choice. This article dives into how sync.Map works under the hood, from its two-map system to the bottom line of expunged entries.

Read

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

Slices are way more flexible than arrays since they’re basically a layer on top of an array. They can resize dynamically, and you can use append() to add more elements.

Read

Go sync.Pool and the Mechanics Behind It

by Phuong Le on Aug 23, 2024

Instead of just throwing these objects after each use, which would only give the garbage collector more work, we stash them in a pool (sync.Pool). The next time we need something similar, we just grab it from the pool instead of making a new one from scratch.

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

Watch Your Monitoring SkyRocket With VictoriaMetrics!