Enhancing Go Integration Tests with Recorder/Replayer

Introduction When developing an application, it’s common to integrate it with third-party services, APIs, and external systems. Testing the integration is a crucial step in ensuring the reliability and correctness of your application. In the Go programming language, you can utilize the built-in net/http/httptest package to test HTTP client/server interactions. While this approach is straightforward, it may not accurately capture real-world interactions or handle complex scenarios involving external services. In this article, I am introducing you to a powerful testing strategy for interacting with third-party servers....

September 19, 2023 · 8 min · Damiano Petrungaro

Domain Driven Design in Golang - Idiomatic application design

Introduction In this article, I will share my approach to structuring Go applications using DDD principles, and highlight some of the tradeoffs that come with this approach. By following the principles outlined in this article, you can create a structure for your Go application that separates concerns between the domain layer, the application layer, and the infrastructure layer making your application more modular, easier to test, and more maintainable over time still maintaining idiomatic Go packaging....

March 21, 2023 · 9 min · Damiano Petrungaro

Go internals - The context package

I am releasing a series of articles to dive deep into the internals of a few packages. If you are interested, I’ll post their release on Twitter and LinkedIn . Context type(s) This article deeps dive into the context types implementation provided by the standard library as part of the context package itself. Disclaimer: This article will not describe how to use the package or what are the best practices. It aims only to describe the internals of the package....

February 17, 2023 · 9 min · Damiano Petrungaro

Go internals - Testing t.Log

This post talks about the internals of the testing package. I am releasing a series of articles to dive deep into the internals of a few packages. If you are interested, I’ll post their release on Twitter and LinkedIn . Internal of the testing Log API Every time in a test we use the Log API from the T type, part of the testing package, what happens behind the scene is more complex than you may think....

January 23, 2023 · 6 min · Damiano Petrungaro

Writing an efficient Go logger - GoLab 2022

Slides

October 2, 2022 · 1 min · Damiano Petrungaro

Data Structure - Binary heap

Introduction This article is part of the data structure category A binary heap is a heap data structure that uses a binary tree to store items. To use a binary tree as a binary heap, it needs to sort the items it stores. The binary heap can store the items in descending order, as a max heap, or in ascending order, as a min heap. To implement a binary tree as a max heap, every parent node must be greater than or equal to its children....

April 3, 2021 · 12 min · Damiano Petrungaro

Data Structure - Queue

Introduction This article is part of the data structure category A queue is an abstract and dynamic data structure. Abstract because its behavior determines it, not by the implementation details, and dynamic, because it can adjust its size once created. A queue implements a method of handling elements named FIFO, first-in first-out, where the first inserted element in the queue is going to be the first one to be picked up; this design makes this data structure excellent for use cases where the order in which the elements must be processed is important....

March 23, 2021 · 5 min · Damiano Petrungaro

Data Structure - Stack

Introduction This article is part of the data structure category A stack is an abstract data structure defined by its behavior rather than its implementation details. It’s also dynamic, meaning it can adjust its size once created. A stack implements a method of handling elements named LIFO, last-in first-out, where the last inserted element in the stack is going to be the first one to be picked up; this design makes the usage of this data structure excellent for use cases, for example, as “undo/redo” (AKA ctrl+z/ctrl+y)....

March 12, 2021 · 6 min · Damiano Petrungaro

Data Structure - Circular buffer

Introduction This article is part of the data structure category A circular buffer (also known as ring buffers, circular queue, or cyclic buffer) is a data structure that uses a fixed-size buffer to store data. The buffer is connected end-to-end, which usually leads to visualizing this data structure as a circle. This detail makes the circular buffer a static data structure, which means its size cannot be adjusted once created....

March 11, 2021 · 5 min · Damiano Petrungaro

Data Structure - Doubly Linked List

Introduction This article is part of the data structure category A linked list is a collection of sequential elements forming a linear data structure. In the linked list, each element of the collection is a node storing a value and, depending on the implementation, one or more links to its neighbouring nodes. This detail makes the linked list a dynamic data structure, which means it can grow or shrink its size....

February 26, 2021 · 11 min · Damiano Petrungaro

Data Structure - Singly Linked List

Introduction This article is part of the data structure category A linked list is a linear data structure formed by a collection of sequential elements. In the linked list, an element is a node that stores a value and, depending on the implementation, one or more link to the next elements. This detail makes the linked list a dynamic data structure, which means it can grow or shrink its size....

February 23, 2021 · 9 min · Damiano Petrungaro

Writing idiomatic Go using Domain Driven Design - GoWay 2020

Video Slides

June 11, 2020 · 1 min · Damiano Petrungaro

Domain Driven Design in Golang - Tactical Design

Introduction In the past few weeks, I received a lot of private and public questions about the first article of the Golang and Domain-Driven Design series I wrote. Most of the questions I received privately were about how to write an entire Golang project (or code in general) using DDD tactical patterns. So I decided to address some of those questions, and I am going to explain more widely my vision about Golang and DDD describing some code patterns I use and trade-offs I always consider....

March 10, 2020 · 19 min · Damiano Petrungaro

Domain Driven Design in Golang - Strategic Design

Introduction In the last year, I have been working more and more with Golang as I used to be a 100% PHP coder before. The community around PHP is terrific, and as a language has a lot of Domain-Driven Design (DDD) advocates. I have been affected by the community about this methodology too, so I’ve been studying and practicing it for the last 3 years. When moving from PHP to Go as an everyday-language, I noticed that DDD doesn’t resonate within the Golang community because most people think it influences an “OOP approach” when writing Go code since the majority of the books and examples about patterns are written in Object-Oriented Design....

January 28, 2020 · 9 min · Damiano Petrungaro