Go Library
4.11K subscribers
20 photos
63 files
798 links
Go (Golang) Library

Реклама: @ostinostin
Контент: @mxssl
Download Telegram
Go slice gotchas

Just like any other dynamically growable container structure, Go slices come with a few gotchas. I don’t always remember all the rules I need to be aware of. So this is an attempt to list some of the most common mistakes I’ve made at least once.


https://rednafi.com/go/slice_gotchas
Why does Go's io.Reader have such a weird signature?

https://rednafi.com/go/io_reader_signature
How I developed a markdown blog in Go and HTMX

https://fluxsec.red/how-I-developed-a-markdown-blog-with-go-and-HTMX
sturdyc

sturdyc eliminates cache stampedes and can minimize data source load in high-throughput systems through features such as request coalescing and asynchronous refreshes. It combines the speed of in-memory caching with granular control over data freshness. At its core, sturdyc provides non-blocking reads and sharded writes for minimal lock contention. The xxhash algorithm is used for efficient key distribution.


https://github.com/viccon/sturdyc
go-taskflow

A General-purpose Task-parallel Programming Framework for Go, inspired by taskflow-cpp, with Go's native capabilities and simplicity, suitable for complex dependency management in concurrent tasks.


https://github.com/noneback/go-taskflow
easycache

EasyCache is a high-performance, in-memory caching library for Go, supporting multiple eviction policies like FIFO, LRU, LFU, and TTL-based expiration. It is thread-safe, lightweight, and provides built-in metrics.


https://github.com/hugocarreira/easycache
httptap

View the HTTP and HTTPS requests made by any linux program by running httptap -- <command>.


https://github.com/monasticacademy/httptap
How to release to Homebrew with GoReleaser, GitHub Actions and Semantic Release

https://dev.to/hadlow/how-to-release-to-homebrew-with-goreleaser-github-actions-and-semantic-release-2gbb
Real-Time Batching in Go

Batching is a well-known optimization technique. You see it everywhere: batch inserts in databases, MGET/MSET in Redis, various bulk APIs. The benefits are clear — it’s faster, cheaper, and less rate-limited. These benefits usually come at the cost of slightly more complex code and some boilerplate.


https://destel.dev/blog/real-time-batching-in-go
Recover panics in all Goroutines you start

I recently joined a project where the codebase was written in Go. While the codebase had numerous issues, one stood out: the server restarted unexpectedly and frequently. After examining the server logs, I discovered the culprit—panic-induced crashes in Goroutines. The underlying issue was that the codebase didn’t handle panic recovery in all the Goroutines it started.


https://dev.ribic.ba/recover-panics-goroutines
zog

Zog is a schema builder for runtime value parsing and validation. Define a schema, transform a value to match, assert the shape of an existing value, or both. Zog schemas are extremely expressive and allow modeling complex, interdependent validations, or value transformations.


https://github.com/Oudwins/zog
genqlient

genqlient is a Go library to easily generate type-safe code to query a GraphQL API. It takes advantage of the fact that both GraphQL and Go are typed languages to ensure at compile-time that your code is making a valid GraphQL query and using the result correctly, all with a minimum of boilerplate.


https://github.com/Khan/genqlient
peerdb

Fast, Simple and a cost effective tool to replicate data from Postgres to Data Warehouses, Queues and Storage


https://github.com/PeerDB-io/peerdb
Faster Go maps with Swiss Tables

Swiss Tables are a form of open-addressed hash table, so let’s do a quick overview of how a basic open-addressed hash table works.


https://go.dev/blog/swisstable
The cost of Go’s panic and recover

TL;DR

- Some of the wisdom contained in Josh Bloch’s Effective Java book is relevant to Go.
- panic and recover are best reserved for exceptional circumstances.
- Reliance on panic and recover can noticeably slow down execution, incurs heap allocations, and precludes inlining.
- Internal handling of failure cases via panic and recover is tolerable and sometimes beneficial.


https://jub0bs.com/posts/2025-02-28-cost-of-panic-recover
Testing concurrent code with testing/synctest

https://go.dev/blog/synctest