Welcome to Memory Notes!

This cozy corner of the internet is my personal treasure chest of knowledge, packed with handy info, code snippets, and quick notes I’ve gathered along my journey. It’s all about building a go-to stash of insights for those “aha!” moments. If you find a gem in here that brightens your day or solves a puzzle, that’s a win in my book!

Simplifying Concurrent Code with Request Sequencing in Go

In the world of concurrent programming, managing simultaneous requests for the same resource or user can quickly become a nightmare of race conditions, complex locking mechanisms, and hard-to-debug issues. What if there was a way to eliminate these concurrency concerns entirely for specific use cases? Enter request sequencing—a pattern that ensures requests for the same entity are processed one at a time, dramatically simplifying your codebase while maintaining system responsiveness. ...

May 29, 2025 · 4 min · Kirill Sysoev

Building a Event System in Go Without Union Types

One challenge in Go development is the absence of union types, which can make it tricky to design clean interfaces for event processing systems. When working with various event types with different payloads, we often resort to type assertions or empty interfaces, resulting in verbose and potentially error-prone code. In this post, I’ll demonstrate a pattern that creates a convenient, structured event interface without relying on union types. The Problem When designing event-driven systems, we typically need to: ...

May 1, 2025 · 4 min · Kirill Sysoev

How to Develop a Custom Plugin for protoc

This guide will walk you through the steps to create a plugin for protoc, the protocol buffer compiler. A plugin allows you to generate custom code based on your .proto files. Step 1: Set Up Your Project Create a new directory for your plugin and initialize a new Go module: mkdir myprotocplugin cd myprotocplugin go mod init myprotocplugin Step 2: Define the Main Function Your plugin will read a CodeGeneratorRequest from standard input and write a CodeGeneratorResponse to standard output. Start by creating a main.go file: ...

July 8, 2024 · 3 min · Kirill Sysoev

Optimizing Go Applications: Mastering Request Deduplication Techniques

In the evolving landscape of software development, particularly within distributed systems and services that demand idempotency, the challenge of managing duplicate requests has emerged as a important concern. This article delves into the concept of request deduplication in the Go programming language, a technique pivotal for enhancing the efficiency and reliability of applications. Request deduplication, at its core, aims to identify and mitigate the processing of identical requests multiple times, thereby preventing the common pitfalls associated with such redundancies. ...

June 30, 2024 · 5 min · Kirill Sysoev

Go Custom Profilers

In the ever-evolving landscape of software development, the need for precise and tailored performance analysis has never been more critical. Go, with its robust performance and concurrency model, offers developers a powerful platform for building efficient applications. However, even with Go’s built-in profiling tools, there are scenarios where a more customized approach is necessary to truly understand and optimize your application’s performance. This article dives into the world of custom profilers in Go, showcasing how to extend beyond the standard profiling tools to capture and analyze the specific metrics that matter most to your application. From setting up custom profiling hooks to integrating with Go’s runtime/pprof package, we’ll explore practical examples and techniques to unlock deeper insights into your Go applications. ...

June 23, 2024 · 2 min · Kirill Sysoev

CPU Profiling in Go with pprof

Performance is a critical aspect of any application. Understanding how your program utilizes CPU resources can provide valuable insights into potential bottlenecks and areas for optimization. One of the most effective ways to visualize CPU usage is through a flame chart, a graphical representation of your program’s call stack over time. In the realm of Go, a statically typed, compiled language renowned for its simplicity and efficiency, we have robust built-in tools for performance analysis. One of these tools is the pprof package, which allows us to profile CPU usage among other things. ...

June 16, 2024 · 6 min · Kirill Sysoev

Understanding and Utilizing Error Wrapping in Go

In Go, error handling is a crucial aspect of creating robust and reliable software. One common scenario is when you need to pass an error up the call stack, but also want to add additional context. This is where error wrapping comes into play. Wrapping Errors The fmt package in Go provides a function called Errorf that allows you to create formatted error messages. It also supports a special placeholder %w that can be used to wrap errors with additional context. ...

June 10, 2024 · 2 min · Kirill Sysoev