---
title: "GoLang: Clean Architecture in Projects [VIDEO]"
description: Clean Architecture in Golang projects is essential to search, debug, and enhance the code. Watch the YT video that will show you how to do that correctly.
image: https://blog-hubspot.railwaymen.org/hubfs/Golang-cover2-min.jpeg
---

[![Railwaymen](https://blog-hubspot.railwaymen.org/hs-fs/hubfs/Railwaymen_September2018/Images/logo_bia%C5%82e.png?width=260&height=70&name=logo_bia%C5%82e.png "Railwaymen")](https://railwaymen.org/)

- [Blog Main Page](https://blog-hubspot.railwaymen.org)
- [About Us](https://railwaymen.org/about-us)
- [Our Work](https://railwaymen.org/case-studies)
- [FAQ](https://railwaymen.org/our-ai-knowledge-base)
- [Contact Us](https://railwaymen.org/contact-us)

![golang: clean architecture in projects \[video\]](https://blog-hubspot.railwaymen.org/hs-fs/hubfs/Golang-cover2-min.jpeg?width=1320&name=Golang-cover2-min.jpeg)

[Web Development](https://blog-hubspot.railwaymen.org/tag/web-development)

# GoLang: Clean Architecture in Projects \[VIDEO\]

- [Michał Szymański, Senior RoR Developer](https://blog-hubspot.railwaymen.org/author/michał-szymanski-senior-ror-developer)
- [1st September '20](https://blog-hubspot.railwaymen.org/golang-clean-architecture-in-projects)

I am sure that every developer (at least once) has to work in unsystematic code files. There is nothing more annoying. Today, I want to show you how organizing application code can improve your work. During years of my career, I had opportunities to implement a **Clean Architecture** approach in projects. In my opinion, it works very well, and it is worth using.

There are many reasons why we should keep the specific structure. First of all, it is much easier to search, debug, and enhance the code. Keep in mind that the project will probably grow in size, and the team has to be able to implement the changes quickly. Speaking about teams, most of us are cooperating with colleagues in daily work - this also happens in the [Railwaymen software house](https://railwaymen.org/about-us) where I work. In that case, the code organization is significant. It is much more comfortable to manage and maintain the organized code structure. I strongly advise you to practice this as a habit.

![01-min](https://blog-hubspot.railwaymen.org/hs-fs/hubfs/01-min.jpeg?width=700&name=01-min.jpeg)

### Table of Contents:

[1. Main layers of the architecture.](https://blog-hubspot.railwaymen.org/golang-clean-architecture-in-projects#p1)

[1.1. Entities.](https://blog-hubspot.railwaymen.org/golang-clean-architecture-in-projects#p1.1)

[1.2. Use Cases.](https://blog-hubspot.railwaymen.org/golang-clean-architecture-in-projects#p1.2)

[1.3. Data provider.](https://blog-hubspot.railwaymen.org/golang-clean-architecture-in-projects#p1.3)

[1.4. Interfaces / Adapters.](https://blog-hubspot.railwaymen.org/golang-clean-architecture-in-projects#p1.4)

[2. General benefits of clean architecture.](https://blog-hubspot.railwaymen.org/golang-clean-architecture-in-projects#p2)

## Main layers of the architecture

### Entities

- Represent your domain object e.g. User, Game Level
- Apply only logic that is applicable in general to the whole entity (e.g., validating the format of a user’s email)
- Implemented as plain objects with no frameworks and external dependencies

Entities are the heart of clean architecture and contain any business rules and logic. The goal is that they contain principles that are not application specific — so basically any global or shareable logic that could be reused in other applications should be encapsulated in an entity, e.g. the user has to have an email address.

An entity is a set of related business rules that are critical to the function of the application. In an object oriented programming language the rules for an entity would be grouped together as methods in a class. The entities know nothing of the other layers. They don’t depend on anything. That is, they don’t use the names of any other classes or components that are in the outer layers. Here is an example structure of User.

```

package models 

type User struct { 
  ID         int64  `json:"id"` 
  shopify_ID  string  `json:"shopyfi_id"` 
  Name        string `json:"name"` 
  Score       int  `json:"score"` 
  Email       string  `json:"email"` 
  Tags        []string `json:"tags"`} 

func (u *User) GetShopifyID() int64 { 
   return u.shopify_ID
}
 
```

### Use Cases

Moving up from the entities we have the **Use Case** layer. The classes that live here have a few unique features and responsibilities:

- Represent your business actions: it’s what your application can do. Expect one use case for each business action
- Pure business logic, plain code (except maybe some utils libraries)
- The use case doesn’t know who triggered it and how the results are going to be presented (for example, user synchronization, adding tags for users)

```

package usecase import ( "./shopify-game-player/player/models" 
         "./shopify-game-player/player/repository"
) 
type UserUsecase struct { 
  userRepo        repository.UserRepo 
  userShopifyRepo repository.UserShopify
}
func NewUserUseCase(userRepo repository.UserRepo, 
                    userShopifyRepo repository.UserShopify) 
*UserUsecase { 
   return &UserUsecase{  
      userRepo:        userRepo,  
      userShopifyRepo: userShopifyRepo, 
   }

} 
func (userUseCase *UserUsecase) FetchUsers(userCount int) []models.User { 
   return userUseCase.userShopifyRepo.Fetch(userCount)
} 

func (userUseCase *UserUsecase) AddTagsToShopifyUsers(userID string, tags string) models.User { 
   return userUseCase.userShopifyRepo.AddTags(userID, tags)
}
 
```

### Data provider

- Retrieve and store data from and to a number of sources (database, network devices, file system)
- Implement the interfaces defined by the use case
- we can use framework to connect to database

For database interactions it is recommended to use the **Repository Pattern** which encapsulates all your database interactions through an abstraction layer. The repository pattern does give you a bit freedom to replace databases with ease.

```

//UserRepo struct for handling db
type UserRepo struct { DB *sql.DB}

// NewMysqlUserRepository will create an implementation of user.Repository
func NewMysqlUserRepository(db *sql.DB) *UserRepo { 
   return &UserRepo{  DB: db, }
}

//FindAll use for find all uses
func (repo *UserRepo) FindAll() (*[]models.User, error) { 
   results, err := repo.DB.Query("SELECT * FROM users") 
   if err != nil {  
     panic(err.Error()) 
   } 
   defer results.Close()  
   var user models.User 
   var users []models.User 
   for results.Next() {  
     err = results.Scan(&user.ID, &user.Name, &user.Score, &user.Shopify_ID)  
     if err != nil {   
       panic(err.Error()) 
     }  
     users = append(users, user) }  
   return &users, err
}
 
```

### Interfaces / Adapters

- Implement the interfaces defined by the use case
- There are ways to interact with the application, and typically involve a delivery mechanism (for example, REST APIs, scheduled jobs, GUI, other systems)

## General benefits of clean architecture:

- Independent of framework
- Independent of UI
- Independent of Database and Frameworks. The software is not dependent on an ORM or Database. You can change them easily.
- Testable. Now it is intrinsically testable. You can test business rules without considering UI, Database, Mock servers, etc.

As you can see, we have to remember several general rules while focusing on clean architecture. **Watch the video** (ENG subtitles are available in the options) and gain knowledge about this approach 👇

[![Railwaymen TechTalk Episode 11: GoLang - Clean Architecture in Projects](https://i.ytimg.com/vi/jCSIllV9d0M/hqdefault.jpg)](https://www.youtube.com/watch?v=jCSIllV9d0M)

```
 
```

**And if you want to know more about our web development services and how we use Go and other programming languages to create apps of an awesome quality - check the place below!**

 

**[Railwaymen Web Development Services](https://railwaymen.org/services/web-development)**

 

 

[Web Development](https://blog-hubspot.railwaymen.org/tag/web-development)

- Share:
- <https://twitter.com/share?text=GoLang:%20Clean%20Architecture%20in%20Projects%20[VIDEO]&url=https://blog-hubspot.railwaymen.org/golang-clean-architecture-in-projects>
- <http://www.facebook.com/sharer/sharer.php?u=https://blog-hubspot.railwaymen.org/golang-clean-architecture-in-projects>
- <http://www.reddit.com/submit?url=https://blog-hubspot.railwaymen.org/golang-clean-architecture-in-projects&title=GoLang:%20Clean%20Architecture%20in%20Projects%20[VIDEO]>
- <https://www.pinterest.com/pin/create/button/?url=https://blog-hubspot.railwaymen.org/golang-clean-architecture-in-projects>
- <http://www.linkedin.com/shareArticle?mini=true&url=https://blog-hubspot.railwaymen.org/golang-clean-architecture-in-projects>

![Michał Szymański, Senior RoR Developer](https://blog-hubspot.railwaymen.org/hubfs/Group%201-8%20(1).png)

Author

#### [Michał Szymański, Senior RoR Developer](https://blog-hubspot.railwaymen.org/author/michał-szymanski-senior-ror-developer)

- <https://www.linkedin.com/in/michal-szymanski-01a6a25/>

 Michał is an experienced RoR and Go software developer. After work, he is an active person, who loves running or cycling around the Kraków.

##### [![how gpt-5 will change your business and give you a competitive edge?](https://blog-hubspot.railwaymen.org/hs-fs/hubfs/GPT-5%20(1).jpg?width=305&name=GPT-5%20(1).jpg) Related Article Business and Technology How GPT-5 will change your business and give you a competitive edge? 5 min read Full Article](https://blog-hubspot.railwaymen.org/gpt-5-revolution-business-advantage)

##### [![how to build a scalable microservice architecture?](https://blog-hubspot.railwaymen.org/hs-fs/hubfs/pexels-jean-daniel-4006158.jpg?width=305&name=pexels-jean-daniel-4006158.jpg) Related Article Business and Technology How to build a scalable microservice architecture? 19 min read Full Article](https://blog-hubspot.railwaymen.org/scalable-microservice-architecture)

##### [![how rag makes generative ai truly reliable for your business?](https://blog-hubspot.railwaymen.org/hs-fs/hubfs/what%20is%20rag%20in%20ai.jpg?width=305&name=what%20is%20rag%20in%20ai.jpg) Related Article Business and Technology How RAG Makes Generative AI Truly Reliable for Your Business? 7 min read Full Article](https://blog-hubspot.railwaymen.org/how-rag-makes-gen-ai-reliable-for-business)

## [![why use golang to build your business app in 2025? \[6 benefits\]](https://blog-hubspot.railwaymen.org/hs-fs/hubfs/golang-cover-min.png?width=1905&height=510&name=golang-cover-min.png) Next Post --- Why use Golang to build your business app in 2025? \[6 Benefits\] Web Development](https://blog-hubspot.railwaymen.org/why-use-golang-to-build-your-business-app)

[![Railwaymen Logo](https://railwaymen.org/assets/svgs/rwm-logo-white-ae5182ba602bcbf3713fd6bb3a5288956e484b62ddf1c647e53f2fb72644913d.svg)](https://railwaymen.org)

 Railwaymen Sp. z o.o.   
 Email: info@railwaymen.org   
 NIP: 6793065841

[![European Funds Smart Growth](https://railwaymen.org/assets/icons/logos/unia-98bb8c7ed12fa79f2ddbe0e00b222213700102dba79748d59f43a304d9803de6.png)](https://railwaymen.org/grants)

[Estimate Project](https://railwaymen.org/estimate-project) [Newsletter Subscribe](https://learn.railwaymen.org/newsletter)

- <https://www.linkedin.com/company/railwaymen>
- <https://www.facebook.com/railwaymen.software.development>
- <https://www.youtube.com/channel/UCu5v1NuohjsTZXGV4K60KWA>
- <https://www.instagram.com/railwaymen_org>
- <https://twitter.com/Railwaymen_org>
- <https://dribbble.com/Railwaymen_org>
- <https://www.behance.net/railwaymen>

##### Company

- [Services](https://railwaymen.org/services)
- [Our Work](https://railwaymen.org/case-studies)
- [About us](https://railwaymen.org/about-us)
- [Blog](https://blog.railwaymen.org)
- [Career](https://railwaymen.org/careers)
- [Personal Data Protection](https://railwaymen.org/personal-data-protection)
- [Cookies Policy](https://railwaymen.org/docs/Cookie_Policy.pdf)
- Cookie Settings

##### Services

- [Web Development](https://railwaymen.org/services/web-development)
- [Mobile Development](https://railwaymen.org/services/mobile-development)
- [Product Design](https://railwaymen.org/services/product-design)
- [Discovery Phase](https://railwaymen.org/services/discovery-phase)
- [MVP Development](https://railwaymen.org/services/mvp-development)
- [Digital Transformation](https://railwaymen.org/services/digital-transformation)
- [Social Networking Software](https://railwaymen.org/services/social-networking-software)
- [Restaurant App Development](https://railwaymen.org/services/restaurant-app-development)
- [Construction Sofware Development](https://railwaymen.org/services/construction-software-development)
- [Custom Marketing Software Development](https://railwaymen.org/services/custom-marketing-software-development)
- [FinTech App Development](https://railwaymen.org/services/fintech-development)

##### Our Experts Must - Reads

- [Is Ruby on Rails Dead in 2025?](https://blog.railwaymen.org/is-ruby-on-rails-dead)
- [How to Start an App Development Project? \[Checklist\]](https://blog.railwaymen.org/checklist-what-you-have-to-do-to-start-the-app-development-project)
- [How to Build an MVP? \[5 Steps\]](https://blog.railwaymen.org/how-to-build-an-mvp)
- [How Long Does it Take to Make An App in 2025?](https://blog.railwaymen.org/how-long-does-it-take-to-make-an-app)
- [Agile Discovery Phase: a Must Have for Your Business](https://blog.railwaymen.org/why-a-discovery-phase-is-a-must-have-for-your-project)
- [Railwaymen App Development Cost Breakdown - How Much do We Charge and Why?](https://blog.railwaymen.org/app-development-cost-breakdown)
- [FAQ: Web & Mobile Development With Us Explained](https://blog.railwaymen.org/railwaymen-faq-web-and-mobile-development-with-us-explained)

 Awards

[![Clutch Recognition Best B2B Companies Global](https://railwaymen.org/assets/awards/Top_B2B_Companies_Global_2018-5d1c8e5358737540e214ce8d51e450fe06ac4be35a0a220c0c2ccfa912787879.png)](https://clutch.co/profile/railwaymen)[![Clutch Recognition Best Ruby on Rails Developers](https://railwaymen.org/assets/awards/ClutchAward2021-013bdba335eecb6eb59319b0475d099899bbb2fa50e4596186ea2126d5b606af.png)](https://clutch.co/press-releases/recognizes-top-performing-development-companies-poland-2021)[![Clutch Top Ruby on Rails Developer Poland 2022](https://railwaymen.org/assets/awards/ClutchTopSoftwareDeveloperPoland_2022-d094b46bd3ce96c9355d21d0c6a05bc4f5959ec255f6815af8797c0a938a6b9e.png)](https://clutch.co/profile/railwaymen)[![Clutch Top React Native Developer Poland 2022](https://railwaymen.org/assets/awards/ClutchTopReactNativePoland_2022-a50094d73ac73fec5c868c5544048db746c9a086fcbe9e7dcf3644875c47762c.png)](https://clutch.co/profile/railwaymen)[![Clutch Top Ruby on Rails Developer Poland 2022](https://railwaymen.org/assets/awards/ClutchTopRubyOnRailsPoland_2022-dc90eec21384445755158dd53914b6e3ef947e75cfe6dba521822c73bd64b789.png)](https://clutch.co/profile/railwaymen)[![Clutch Top Software Developer Fintech 2022](https://railwaymen.org/assets/awards/ClutchTopSoftwareDeveloperFintech_2022-ba75658f45c04d38d0fa4f9dcbfc78e2982b62222d681d6dc3f2f40fe2cafc9b.png)](https://clutch.co/profile/railwaymen)[![Clutch B2B Services 2022](https://railwaymen.org/assets/awards/Best-PerformingB2B2022-4a7057260a703088e644083b31320fe6fdafbfe3491eadf7e9a711fa9e3f9174.png)](https://clutch.co/profile/railwaymen)

[![Clutch Recognition Best App Development Company](https://railwaymen.org/assets/awards/TheClutch1000-a5cd5e3433659ee45539838fa945002f147b6ed9065166f8ba9ff56d216173eb.png)](https://blog.railwaymen.org/railwaymen-named-global-leaders-top-10-ruby-on-rails-developers-2018?_gl=1*1lggq91*_gcl_au*MTY4NzY2MDQ5Mi4xNzMxNDAxMDg4*_ga*MTY1MzUxNjI1Ni4xNzMxNDAxMDg4*_ga_1TW68M8Z6C*MTczMjcwMDE4Ny4xNi4xLjE3MzI3MDExMzYuMzIuMC4w)[![Top Software Development Company](https://railwaymen.org/assets/awards/Custom-Software-Development-Companies-1c56b8d73fbc48c21514311021c65f85a53cd955a3f910a9c2347a6c4a934b0f.png)](https://www.softwareworld.co/top-custom-software-development-companies/)[![Hire elite software development vendors at Pangea](https://railwaymen.org/assets/awards/Pangea-3db009da8ad6d19dfdafc66c51d16928730a715c3195776579bff5e0df4c13d4.png)](https://www.pangea.ai/vendors/railwaymen/)[![GoodFirms Badge](https://railwaymen.org/assets/awards/goodfirms-6880d7b6b80ee00d7189656a8236466571c5f94f146a8d42f5421d85f53b05df.svg)](https://www.goodfirms.co/company/railwaymen)[![Digital Knights](https://railwaymen.org/assets/awards/dk-8e9cb01c4fb52cd6dd812212e5d6925772aa6399c71d47387e3f8a8d5d58ac59.svg)](https://www.digitalknights.co/)

Railwaymen locations

- Kraków
  
  Na Zjeździe 11, 30-527
- San Francisco
  
   Silicon Valley Acceleration Center. 180 Sansome Street

 You can change your cookie settings at any time Close and don't show again

© 2026 Railwaymen

```json
{
  "@context" : "https://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Michał Szymański, Senior RoR Developer",
    "url" : "https://blog-hubspot.railwaymen.org/author/michał-szymanski-senior-ror-developer"
  },
  "dateModified" : "2023-03-28T15:44:14.803Z",
  "datePublished" : "2020-09-01T06:56:15.000Z",
  "headline" : "GoLang: Clean Architecture in Projects [VIDEO]",
  "image" : [ "https://blog-hubspot.railwaymen.org/hubfs/Golang-cover2-min.jpeg" ],
  "mainEntityOfPage" : {
    "@id" : "https://blog-hubspot.railwaymen.org/golang-clean-architecture-in-projects",
    "@type" : "WebPage"
  },
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "url" : "https://blog-hubspot.railwaymen.org/hubfs/new%20website/rwm%20logotype.png"
    },
    "name" : "Railwaymen Sp. z o.o."
  }
}
```