Golang Digest
2.54K subscribers
164 photos
1 video
190 links
Everything about Go: news, articles, tools, language changes, etc.

#go #golang #concurrency #postgres #database #db
Download Telegram
Iterators in Go

This article explains how to implement and use iterators in Go. It covers the benefits of iterators over traditional slices, such as reduced memory usage and improved efficiency, by yielding one result at a time.

Link to the article

#go #article #iterators
Please open Telegram to view this post
VIEW IN TELEGRAM
👍4🔥3
🧙Go 1.23 Release

The biggest update is the introduction of iterators. The slices and maps packages have been enhanced with new methods for working with iterators. For example, Chunk() method from the slices package allows you to iterate over a slice in batches of a specified number of elements:
 people := People{
{"Gopher", 13},
{"Alice", 20},
{"Bob", 5},
{"Vera", 24},
{"Zac", 15},
}

// Chunk people into []Person 2 elements at a time.
for c := range slices.Chunk(people, 2) {
fmt.Println(c)
}
Additionally, on the optimization front, PGO has been further enhanced, as we mentioned here, here and here. Thanks to more efficient stack usage, these optimizations can now provide a few extra percentage points of resource savings and performance improvements at no cost.
Please open Telegram to view this post
VIEW IN TELEGRAM
6👍6🔥6