Golang Nugget - January 27, 2025

Alibaba, Datadog, and Quesma team up on Go Compile-Time Instrumentation

In partnership with

  1. Making Beautiful API Keys — Typically, API keys are just random strings, which can be difficult to read and manage. But to have a good user experience, you need both readable and functional API keys. uuidkey is a package that uses UUIDv7 and Crockford Base32 to address this problem.

  2. Mind The convT — In Go, interfaces don’t come for free and can hurt performance. In one case, DoltDB moved from using an interface to a concrete type and saw a 24% performance improvement in memory-to-wire conversions. If you care about your code’s performance, this is a must-read post.

  3. Writing a circuit breaker in Go — A circuit breaker is a mechanism to prevent overloading failing services by stopping requests during failure periods. It can switch between three states: Closed, Open, and Half-Open. This post walks through how to implement a circuit breaker pattern in Go.

  4. A Deep Dive into Gin: Golang's Leading Framework — Gin is a high-performance HTTP web framework for Go. It offers a Martini-like API but with performance up to 40 times faster. If you haven’t worked with it before, this article could give you a good overview.

  5. Exploring the new "go tool" support in Go 1.24 — Go 1.24 introduces a new way to use tools directly via the tool directive. Although it’s amazing, it’s verbose and slower than using tools directly. This post shares some tips on mitigating these issues for smoother tool usage.

Tool Time

  1. github.com/nikoksr/notify — A dead-simple Go library for sending notifications to various messaging services, including Amazon SNS, Firebase, Discord, Slack, WhatsApp, and more! This Go library makes it super easy to integrate notification features into your code.

  2. github.com/FreeLeh/GoFreeDB — A handy Go library that makes it easy to use Google Sheets as a simple database. It offers straightforward key-value and row-based interfaces to interact with Google Sheets.

  3. github.com/cshum/imagor — If you’re looking for a fast way to process images in Go, check imagor out. It works both as a library and a server that lets you perform various image transformations and apply filters.

  4. mgechev/revive v1.6.0 — revive is a go linter and v1.6.0 just got released. It offers two new rules.

    • use-errors-new that proposes replacing fmt.Errorf by errors.New when possible.

    • redundant-build-tag that spots redundant build tags.

Here’s Why Over 4 Million Professionals Read Morning Brew

  • Business news explained in plain English

  • Straight facts, zero fluff, & plenty of puns

  • 100% free

Deep Dive

OpenTelemetry is a project that provides standards and tools for collecting telemetry data (traces, metrics, and logs) from applications.

If you want to use OpenTelemetry in Go, you have two options:

  • Use a separate binary that analyses your Go process and attaches eBPF programs to hooks in your application.

  • Manually configure instrumentation libraries in your code.

Both are not ideal, as the first one introduces complexity, and the latter requires a lot of code changes.

Now, to improve it, compile-time instrumentation has been proposed as a new approach. This will use the Go toolchain’s toolexe to rewrite Go source code before it is passed to the Go compiler, adding instrumentation in all relevant places (including dependencies as well as the Go standard library).

Both Alibaba and Datadog have each proposed a solution for compile-time instrumentation, but now they’re teaming up to form a new Go Compile-Time Instrumentation Special Interest Group to solve the issue.

If you want to contribute, here are some links:

How did you like this edition?

Or hit reply and share your thoughts!

Login or Subscribe to participate in polls.

Reply

or to participate.