Understanding the Importance of Separating DTO, Entity and Model in Application Development

In Golang application development, we often find a single struct object used for various purposes, such as representing data in the database as well as payload in API requests and responses. Although this seems practical, this approach can actually create problems related to security and maintenance. This article will discuss the importance of separating DTO, Entity and Model by applying some Domain-Driven Design (DDD) principles. ...

January 26, 2025 · 8 min · 1568 words · Muchlis

Database Transaction Implementation Techniques in Logic Layer for Golang Backend

Database transactions are a crucial aspect in application development, especially in projects that demand high data consistency. This article will discuss how to perform database transactions in the service layer (logic), while maintaining clean architecture principles and separation of concerns. ...

October 12, 2024 · 10 min · 1920 words · Muchlis

Pagination Optimization: Why Limit-Offset Can Be a Time Bomb and Cursor Pagination as the Solution

Pagination is a technique for dividing database query results into smaller chunks. Using LIMIT OFFSET queries is the most commonly used method. However, this method has several weaknesses, especially in terms of performance on very large datasets. This article will discuss problems that arise when using LIMIT OFFSET and explore more efficient alternatives, such as cursor-based pagination and seek method. ...

August 11, 2024 · 12 min · 2492 words · Muchlis

Folder Structure and Code Writing Rules in Golang Projects: Personal Preferences

Often, the Golang programs we create are not just REST-API servers, but also include other functions such as Event Consumers, Schedulers, CLI Programs, Database Backfills, or combinations of all of them. This project structure guideline can be used to enable all of that. This structure focuses on separating core logic from external dependencies, allowing code reuse across various application modes. Repository Link: https://github.com/muchlist/templaterepo ...

July 20, 2024 · 9 min · 1809 words · Muchlis

Pay Attention to These Things When Using Golang Goroutines

In backend development with Golang, managing background processes using goroutines is a common practice that can improve application performance. However, there are several common problems often encountered when implementing goroutines, especially regarding panic handling, context management, and proper shutdown processes. This article will review some common mistakes related to goroutine usage and how to overcome them. ...

December 26, 2022 · 4 min · 827 words · Muchlis at eFishery