Recent Articles
Golang Release 1.21: cmp
New package in Go standard library that makes easier to compare ordered types.
Not too long ago, we witnessed a new release of our favorite programming language. The Go team didn’t disappoint us once again. They introduced numerous new features, including updates to the tool command to support backward and forward compatibility. As always, the standard library has received new updates, and the first one we’ll explore in this article is the new cmp package.
The new package offers three new functions. All of them rely on Generics, a feature introduced in Go version 1.
read more
Golang Release 1.21: maps
New package in Go standard library that makes easier to work with maps.
Not too long ago, we witnessed a new release of our favorite programming language. The Go team didn’t disappoint us once again. They introduced numerous new features, including updates to the tool command to support backward and forward compatibility. As always, the standard library has received new updates, and the first one we’ll explore in this article is the new maps package.
The new package offers only five new functions (two additional ones were removed from the package: Values and Keys), but they provide significant value.
read more
Golang Tutorial: Generics with Gorm
Can we expect to have a comprehensive ORM and DBAL framework, similar to Doctrine, for Go?
After months and years of talking, trying things out, and testing, we’ve finally reached a big moment in our favorite programming language. The new Golang version, 1.18, is here. We knew it would bring significant changes to Go’s codebase, even before Generics was officially released. For a long time, when we wanted to make our code more general and abstract, we used code generators in Go. Learning what the “Go way” of doing things was challenging for many of us, but it also led to many breakthroughs.
read more
Golang Tutorial: Unit Testing with Mocking
Techniques that have helped me have zero bugs in production for 2 years.
Unit testing has always been my thing, almost like a hobby. There was a time when I was obsessed with it, and I made sure that all my projects had at least 90% unit test coverage. You can probably imagine how much time it can take to make such a significant change in the codebase. However, the result was worth it because I rarely encountered bugs related to business logic. Most of the issues were related to integration problems with other services or databases.
read more
Golang Tutorial: Generics
One feature to rule them all.
How often do we encounter significant changes in our preferred programming language? Some languages undergo frequent updates, while others remain traditional and stable. Go falls into the latter category, known for its consistency. “This is not the Go way!” is a phrase that often comes to mind. Most Go releases have focused on refining its existing principles. However, a major shift is on the horizon. The Go team has announced that Generics in Go are becoming a reality, moving beyond mere discussion and into implementation.
read more
Practical SOLID in Golang: Dependency Inversion Principle
We continue our journey through the SOLID principles by presenting the one that has the most significant impact on unit testing in Go: The Dependency Inversion Principle.
Learning a new programming language is often a straightforward process. I often hear: “The first programming language you learn in a year. The second one in a month. The third one in a week, and then each next one in a day.” Saying that is an exaggeration, but it is not too distant from the truth in some cases. For example, jumping to a language relatively similar to the previous one, like Java and C#, can be a straightforward process.
read more
Practical SOLID in Golang: Interface Segregation Principle
We continue our journey through the SOLID principles by discussing the one that has a profound impact on code design: The Interface Segregation Principle.
When beginners embark on their programming journey, the initial focus is typically on algorithms and adapting to a new way of thinking. After some time, they delve into Object-Oriented Programming (OOP). If this transition is delayed, it can be challenging to shift from a functional programming mindset. However, eventually, they embrace the use of objects and incorporate them into their code where necessary, sometimes even where they’re not needed. As they learn about abstractions and strive to make their code more reusable, they may overgeneralize, resulting in abstractions applied everywhere, which can hinder future development.
read more
Practical SOLID in Golang: Liskov Substitution Principle
We continue our journey through the SOLID principles by presenting the one with the most complex definition: The Liskov Substitution Principle.
I’m not really a fan of reading. Often, when I do read, I find myself losing track of the text’s topic for the past few minutes. Many times, I’ll go through an entire chapter without really grasping what it was all about in the end. It can be frustrating when I’m trying to focus on the content, but I keep realizing I need to backtrack. That’s when I turn to various types of media to learn about a topic.
read more
Practical SOLID in Golang: Open/Closed Principle
We continue our journey through the SOLID principles by presenting the one that enhances the flexibility of applications: The Open/Closed Principle.
Many different approaches and principles can lead to long-term improvements in our code. Some of them are well-known in the software development community, while others remain somewhat under the radar. In my opinion, this is the case with The Open/Closed Principle, represented by the letter O in the word SOLID. In my experience, only those genuinely interested in SOLID principles tend to understand what this principle means. We may have applied this principle without even realizing it in some instances, such as when working with the Strategy pattern.
read more