<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/duvyixxeu" -->

---
title: My favorite Go Backend architecture pattern | daily.dev
description: A Go developer with 3+ years of backend experience shares their preferred layered architecture pattern for Go projects. The pattern uses three layers — Handler...
canonical: https://daily.dev/posts/duvyixxeu
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: My favorite Go Backend architecture pattern | daily.dev
og:description: A Go developer with 3+ years of backend experience shares their preferred layered architecture pattern for Go projects. The pattern uses three layers — Handler...
og:url: https://daily.dev/posts/duvyixxeu
og:image: https://api.daily.dev/og/posts/DUvyIXxeu.png
og:image:alt: Post cover image
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# My favorite Go Backend architecture pattern

**[scopespace](https://daily.dev/sources/scope_space)** · [@fab978](https://daily.dev/fab978) · 235 upvotes · 12 comments

## Summary

A Go developer with 3+ years of backend experience shares their preferred layered architecture pattern for Go projects. The pattern uses three layers — Handler (Controller), Service, and Repository — each backed by an interface and a single shared struct using Go's embedding feature. Code examples show how Gin is used for routing, GORM for database access, and how interfaces enable easy mocking for unit tests. A shared 'pkg' package pattern using functional options (InitialOption) is also demonstrated for reusable integrations. The post also honestly discusses a known limitation: handling database transactions that span business logic across Service and Repository layers is awkward compared to Spring Boot's @Transactional annotation.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://medium.com/@antooo5113/my-favorite-go-back-end-architecture-pattern-122a5affd370>

## Community discussion

Top comments from developers on daily.dev.

**@stephenvuong** · 14 upvotes

> Should be `NewServices()` returning `Services`.

**@bob72** · 7 upvotes

> Your AI generated sloppy image does not make any sense.
>
> Also, using mockery is a nightmare, at some point you can't trust tests anymore, proper integration tests must be implemented.

**@secondinstance** · 3 upvotes

> I prefer GoFiber over all other frameworks for Go.

**@clarkesp** · 1 upvotes

> My Ai says you are wrong

**@evgenylugin** · 1 upvotes

> Don’t use GORM. Never

## Similar posts on daily.dev

- [Don’t just attend KubeCon \+ CloudNativeCon, Merge Forward your experience\!](https://daily.dev/posts/don-t-just-attend-kubecon-cloudnativecon-merge-forward-your-experience--l0rpp73x8) · CNCF · 1 upvotes · 0 comments
- [Announcing H2 2026 KCDs](https://daily.dev/posts/announcing-h2-2026-kcds-m96goajm1) · CNCF · 1 upvotes · 0 comments
- [Two months of Open Community Groups](https://daily.dev/posts/two-months-of-open-community-groups-asf52zhbs) · CNCF · 0 upvotes · 0 comments
- [CNCF Unveils Schedule for KubeCon \+ CloudNativeCon Europe 2026](https://daily.dev/posts/cncf-unveils-schedule-for-kubecon-cloudnativecon-europe-2026-ikhcoa5cb) · CNCF · 2 upvotes · 0 comments
- [CNCF Debuts KubeCon \+ CloudNativeCon Japan 2026 Schedule](https://daily.dev/posts/cncf-debuts-kubecon-cloudnativecon-japan-2026-schedule-xp5pyudub) · CNCF · 1 upvotes · 0 comments

---

Tags: [#golang](https://daily.dev/tags/golang)

[View this post on daily.dev](https://daily.dev/posts/duvyixxeu)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"DiscussionForumPosting","mainEntityOfPage":"https://daily.dev/posts/duvyixxeu","headline":"My favorite Go Backend architecture pattern","text":"Shared: My favorite Go Backend architecture pattern","url":"https://daily.dev/posts/duvyixxeu","datePublished":"2026-05-04T22:37:59.717Z","dateModified":"2026-05-04T22:38:42.118Z","author":{"@type":"Person","name":"Furqan ahmad","url":"https://daily.dev/fab978","image":"https://media.daily.dev/image/upload/s--GY0VPIs1--/f_auto/v1788339486/avatars/avatar_01YKXdhx6XxiWycQaD2rh?_a=BAMAMicg0","description":"\nFull Stack & Backend Developer | Open to Remote Opportunities","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":3550}},"image":"https://media.daily.dev/image/upload/s--58gMhC4P--/f_auto/v1722860399/public/Placeholder%2012","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":235},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":12}],"sharedContent":{"@type":"WebPage","url":"https://api.daily.dev/r/w6VNpgfgY"},"comment":[{"@type":"Comment","text":"Should be NewServices() returning Services.","datePublished":"2026-05-05T07:32:38.679Z","url":"https://daily.dev/posts/DUvyIXxeu#c-fKco2eqyP","author":{"@type":"Person","name":"Thành Vương","url":"https://daily.dev/stephenvuong","image":"https://lh3.googleusercontent.com/a/ACg8ocIkcdrsVyTX6qjcX_949XHjtd89zNKMi0Lsic3HGx1rLa1nwzIU=s96-c"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":14}},{"@type":"Comment","text":"Your AI generated sloppy image does not make any sense.\nAlso, using mockery is a nightmare, at some point you can’t trust tests anymore, proper integration tests must be implemented.","datePublished":"2026-05-05T22:36:55.664Z","url":"https://daily.dev/posts/DUvyIXxeu#c-egGAAn49w","author":{"@type":"Person","name":"Bob","url":"https://daily.dev/bob72","image":"https://avatars.githubusercontent.com/u/193962566?v=4"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":7}},{"@type":"Comment","text":"I prefer GoFiber over all other frameworks for Go.","datePublished":"2026-05-06T15:16:59.316Z","url":"https://daily.dev/posts/DUvyIXxeu#c-Z60eUsOgo","author":{"@type":"Person","name":"Jeremy  Peters","url":"https://daily.dev/secondinstance","image":"https://media.daily.dev/image/upload/s--O0TOmw4y--/f_auto/v1715772965/public/noProfile"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":3}},{"@type":"Comment","text":"My Ai says you are wrong","datePublished":"2026-05-06T11:47:08.472Z","url":"https://daily.dev/posts/DUvyIXxeu#c-MtmhgtYlj","author":{"@type":"Person","name":"clarke","url":"https://daily.dev/clarkesp","image":"https://lh3.googleusercontent.com/a/ACg8ocLOPF3GyNAiAAvRVBZy_U_d_jvtQJXtLg-0rBF7WUTXVA=s96-c"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1}},{"@type":"Comment","text":"Don’t use GORM. Never","datePublished":"2026-05-12T17:14:33.828Z","url":"https://daily.dev/posts/DUvyIXxeu#c-OPYMnwhUs","author":{"@type":"Person","name":"Evgeny Lugin","url":"https://daily.dev/evgenylugin","image":"https://lh3.googleusercontent.com/a/ACg8ocKa__MS8hYxSO4PGyZfQ48T_DHy0tlU1jdul2B2qb6MPNSuPTUbnw=s96-c"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1}}],"isPartOf":{"@type":"WebPage","url":"https://daily.dev/squads/scope_space","name":"scopespace"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"scopespace","item":"https://daily.dev/squads/scope_space"},{"@type":"ListItem","position":3,"name":"My favorite Go Backend architecture pattern"}]}
```

