Example go clean architecture folder pattern

Overview

Golang Clean Architecture (Maintenance)

Berikut ini adalah folder structure pattern yang biasa saya gunakan, walaupun tidak semua nya saya terapkan dikarenakan project yang saya kerjakan hanyalah project - project kecil yang tidak terlalu besar, jadi jika anda tertarik dengan pattern yang saya buat ini anda bisa menggunakan nya jika menurut anda baik.

Structure Folder Pattern

├── tests
│   └── test.auth_test.go
│   └── test.student_test.go
└── docker
│   └── swagger
│   │     └── Dockerfile
│   │     └── openapi.yml
│   └── mysql
│   │     └── Dockerfile
│   │     └── mysql.cnf
│   └── golang
│   │     └── Dockerfile
├── handlers
│   └── auth
│   │     └── handler.login.go
│   │     └── handler.register.go
│   └── student
│   │     └── handler.create.go
│   │     └── handler.create.go
└── repositorys
│   └── auth
│   │     └── repository.login.go
│   │     └── repository.register.go
│   └── student
│   │     └── repository.create.go
│   │     └── repository.create.go
└── services
│   └── auth
│   │     └── services.login.go
│   │     └── services.register.go
│   └── student
│   │     └── services.create.go
│   │     └── services.create.go
└── helpers
│   └── helpers.apiResponse.go
│   └── helpers.randomString.go.go
└── middlewares
│   └── middleware.auth.go
│   └── middleware.role.go.go
└── models
│   └── model.auth.go
│   └── model.student.go.go
└── routes
│   └── route.auth.go
│   └── route.student.go
└── schemas
│   └── schema.auth.go
│   └── schema.student.go.go
└── templates
│   └── template.register.html
│   └── template.activation.html
└── pkg
│   └── pkg.jwt.go
│   └── pkg.bcrypt.go
│   └── pkg.cron.go
└── scripts
│   └── gcpRunner.sh
│   └── awsRunner.sh
└── configs
│   └── openapi.yml
│   └── serverless.yml
└── cmd
│   └── cmd.pgMigration.go
│   └── cmd.pgSeeds.go
└── crons
│   └── cron.autoDeleteLogs.go
│   └── cron.emailBlast.go
└── databases
│   └── migrations
│   │     └── migration.auth.go
│   │     └── migration.student.go
│   └── seeds
│   │     └── seed.auth.go
│   │     └── seed.student.go
│   └── sql
│   │     └── sql.auth.sql
│   │     └── sql.student.sql

Table Folder Status

Folder Name Folder Status
tests optional
docker optional
handlers required
repositorys required
services required
helpers optional
middlewares optional
models required
routes required
schemas required
templates optional
pkg optional
scripts optional
configs optional
cmd optional
crons optional
databases optional

Command

  • Application Lifecycle

    • Install node modules
    $ go get . || go mod || make goinstall
    • Build application
    $ go build -o main || make goprod
    • Start application in development
    $ go run main.go | make godev
    • Test application
    $ go test main.go main_test.go || make gotest
  • Docker Lifecycle

    • Build container
    $ docker-compose build | make dcb
    • Run container with flags
    $ docker-compose up -d --<flags name> | make dcu f=<flags name>
    • Run container build with flags
    $ docker-compose up -d --build --<flags name> | make dcubf f=<flags name>
    • Run container
    $ docker-compose up -d --build | make dcu
    • Stop container
    $ docker-compose down | make dcd
Issues
Owner
Restu Wahyu Saputra
A bright future will come, just waiting times, someday I will definitely become a software engineer
Restu Wahyu Saputra
Example go clean architecture folder pattern

Golang Clean Architecture (Maintenance) Berikut ini adalah folder structure pattern yang biasa saya gunakan, walaupun tidak semua nya saya terapkan di

Restu Wahyu Saputra 17 Oct 19, 2021
Golang Clean Architecture based on Uncle Bob's Clean Architecture and Summer internship in 2021

clean-architecture-api Description This is an example of implemention of Clean Architecture in Golang projects. This project has 4 layer : Infrastruct

daiki sakuma 3 Oct 25, 2021
架构师技术图谱,助你早日成为架构师

架构师技术图谱,助你早日成为架构师 本项目是《码农周刊》架构学习资料精选,码农周刊团队官方出品。架构师必读,助你早日成为架构师! 架构师技术图谱包括:分布式、前端、大数据、存储、微服务、推荐系统、框架 、消息队列、编程语言、设计模式、重构、集群等内容。 码农周刊 VIP 会员 = 全年 52 期「V

ToutiaoIO 8.8k Oct 21, 2021
DCI Architecture Implementation

前言 在面向对象编程的理念里,应用程序是对现实世界的抽象,我们经常会将现实中的事物建模为编程语言中的类/对象(“是什么”),而事物的行为则建模为方法(“做什么”)。面向对象编程有三大基本特性(封装、继承/组合、多态)和五大基本原则(单一职责原则、开放封闭原则、里氏替换原则、依赖倒置原则、接口分离原则

元闰子 2 Oct 12, 2021
The Little Go Book is a free introduction to Google's Go programming language

The Little Go Book is a free introduction to Google's Go programming language. It's aimed at developers who might not be quite comfortable with the idea of pointers and static typing. It's longer than the other Little books, but hopefully still captures that little feeling.

Dariush Abbasi 10.2k Oct 20, 2021
Boilerplate for writing Go applications without framework using hexagonal application development approach

Boilerplate for writing Go applications without framework using hexagonal application development approach

Marko Kovačević 12 Oct 17, 2021
Concurrency patterns in Go

Concurrency patterns in Go

Kha Nguyen 1.2k Oct 18, 2021
Cook amazing genetic parts using our cookbook. Recipes and synthetic biology tools to take your breath away.

friendzymes-cookbook Friendly tools for a friendly community. A collection of tutorials and genetic tools for synthetic biology. This cookbook is a su

iGEM Software 2021 2 Oct 24, 2021
functional programming in go

function programming experimental lib why another fp lib I like fp style and I haven’t found a lib with these features: streamingly, I can handle infi

Jason 3 Oct 19, 2021
📁 Examples for 🚀 Fiber - Express inspired web framework written in Go

?? Examples for ?? Fiber - Express inspired web framework written in Go

Fiber 1.1k Oct 25, 2021
Crud with Go Language!

CRUD With GO! CRUD with Go Language! How to use with Docker-Compose git clone this project open the cloned folder in the terminal and cd backend/ run

Yusuf Baş 1 Oct 12, 2021
Go Series | Go 语法基础与工程实践

在线阅读 >> 速览手册 · 代码案例 · 参考资料 Go Series | Go 语法基础与工程实践 Go 语言发展至今已经过去十年多了,是目前最流行的新兴语言,云计算领域的首选语言。回顾过去十年的 Go 设计和开发,Go 社区的发展尤其惊人。

王下邀月熊 99 Oct 12, 2021
Building a shoe store with golang to learn more about this language :)

shoestore-go Building a shoe store with golang to learn more about this language :) TODO Create a basic webpage with the pages: home : to show homepag

Bruno B. Melo 3 Oct 6, 2021
Learn how to write webapps without a framework in Go.

This is an easy to understand example based tutorial aimed at those who know a little of Go and nothing of webdev and want to learn how to write a webserver in Go. You will create a to do list application as you advance the chapters.

Suraj Patil 2.9k Oct 21, 2021
Go-Notebook is inspired by Jupyter Project (link) in order to document Golang code.

Go-Notebook Go-Notebook is an app that was developed using go-echo-live-view framework, developed also by us. GitHub repository is here. For this proj

Arturo Elias 26 Oct 8, 2021
Example code for my Cadence Intro Workshop

Temporal Intro Workshop This repository contains example code for my Temporal Intro Workshop. Prerequisites Git, Make, etc. Make sure you have the lat

Márk Sági-Kazár 6 Oct 16, 2021
Examples of Golang compared to Node.js for learning

This guide full of examples is intended for people learning Go that are coming from Node.js, although the vice versa can work too. This is not meant to be a complete guide and it is assumed that you've gone through the Tour of Go tutorial. This guide is meant to be barely good enough to help you at a high level understand how to do X in Y and doing further learning on your own is of course required.

Miguel Mota 2.6k Oct 25, 2021
A collection of 100+ popular LeetCode problems solved in Go.

go-leetcode A collection of 100+ popular LeetCode problems that I've solved in Go. Each directory includes a: Description with link to LeetCode proble

Austin Gebauer 1.7k Oct 11, 2021
Comparison of Pixel and Ebiten API on the trees tutorial

Rewriting the trees tutorial of Pixel with Ebiten for API comparison I tried Pixel and really liked the clean API but the dev seems to be on pause sin

null 3 Oct 18, 2021