v1: checkout to the v1 branch
Proposed on 2017, archived to v1 branch on 2018
Desc: Initial proposal by me. The story can be read here: https://medium.com/@imantumorang/golang-clean-archithecture-efd6d7c43047
v2: checkout to the v2 branch
Proposed on 2018, archived to v2 branch on 2020
Desc: Improvement from v1. The story can be read here: https://medium.com/@imantumorang/trying-clean-architecture-on-golang-2-44d615bf8fdf
v3: master branch
Proposed on 2019, merged to master on 2020.
Desc: Introducing Domain package, the details can be seen on this PR #21
This is an example of implementation of Clean Architecture in Go (Golang) projects.
Rule of Clean Architecture by Uncle Bob
More at https://8thlight.com/blog/uncle-bob/2012/08/13/the-clean-architecture.html
This project has 4 Domain layer :
The original explanation about this project's structure can read from this medium's post : https://medium.com/@imantumorang/golang-clean-archithecture-efd6d7c43047.
It may different already, but the concept still the same in application level, also you can see the change log from v1 to current version in Master.
Make Sure you have run the article.sql in your mysql
Since the project already use Go Module, I recommend to put the source code in any folder but GOPATH.
$ make test
Here is the steps to run it with docker-compose
#move to directory
$ cd workspace
# Clone into YOUR $GOPATH/src
$ git clone https://github.com/bxcodec/go-clean-arch.git
#move to project
$ cd go-clean-arch
# Build the docker image first
$ make docker
# Run the application
$ make run
# check if the containers are running
$ docker ps
# Execute the call
$ curl localhost:9090/articles
# Stop
$ make stop
In this project, I use some tools listed below. But you can use any simmilar library that have the same purposes. But, well, different library will have different implementation type. Just be creative and use anything that you really need.
go.mod
安装go-ceph库 1.基础环境 CentOS 7.5 golang 1.11 gcc 4.8.5 2.安装golang开发环境 (1)进入golang下载页面,下载golang程序包(go1.11.linux-amd64.tar.gz)。 URL:https://studygolang.com/dl (2)解压golang程序包并拷贝go目录至/usr/local目录下。 [root@loc
制作安装镜像U盘 镜像系统配置 联网 虚拟机或网线 dhcpcd WiFi systemctl start wpa_supplicant.service nmcli dev wifi list nmcli dev wifi connect "ssid" password "passwd" 常见问题 #查看网卡状态 ip link #开启网卡 ip link set 网卡名 up #rfkill
上一篇文章中我们已经成功的运行了go的代码,这是我们迈出的最基础的一步。 一个项目通常会依赖很多外部的库,当依赖的库比较多的时候,手工管理就会比较麻烦,这个时候就需要包管理工具出场了,帮你管理好所有依赖的库。 php项目中使用composer,javascript项目中使用npm,那么在go项目中,我们需要使用什么? 包依赖工具的选择 当前go的包管理工具有glide、godep、govendor
执行 go clean 命令会删除掉执行其它命令时产生的一些文件和目录,包括: 在使用 go build 命令时在当前代码包下生成的与包名同名或者与Go源码文件同名的可执行文件。在 Windows 下,则是与包名同名或者 Go 源码文件同名且带有 .exe 后缀的文件。 在执行 go test 命令并加入 -c 标记时在当前代码包下生成的以包名加 .test 后缀为名的文件。在 Windows 下
Go语言中 命令可以移除当前源码包和关联源码包里面编译生成的文件,这些文件包括以下几种: 执行命令时在当前目录下生成的与包名或者 Go 源码文件同名的可执行文件。在 Windows 下,则是与包名或者 Go 源码文件同名且带有“.exe”后缀的文件。 执行命令并加入标记时在当前目录下生成的以包名加“.test”后缀为名的文件。在 Windows 下,则是以包名加“.test.exe”后缀的文件。
我有一些第三方jar依赖。因此,我使用maven-install-plugin将这些第三方jar安装到我的本地存储库(.m2/repository)中。这个插件一定要清理阶段。当我执行“MVN clean Install”时,在运行clean之前,它开始搜索依赖项,最终构建失败,因为它无法找到第三方JAR。但是当我单独运行mvn clean时,它会将文件安装在本地存储库中。随后当我运行mvn cl
Clean Architecture on Android: the Teamwork.com way! The purpose of this repository is to showcase, with a very simple (but hopefully clear) sample Android project, how we implement Uncle Bob's Clean
The-Force An Android app consuming a Star Wars API to display Movie Charactersit has been built with clean architecture principles, Repository Pattern and MVVMpattern as well as Architecture Compo
Getting Started If you don't have Docker, download it from the address below. https://www.docker.com/products/docker-desktop Download this repository Open onion-architecture.sln with Visual studio Con