当前位置: 首页 > 软件库 > 数据库相关 > >

go-clean-arch

授权协议 MIT License
开发语言 Google Go
所属分类 数据库相关
软件类型 开源软件
地区 不详
投 递 者 程彭祖
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

go-clean-arch

Changelog

Description

This is an example of implementation of Clean Architecture in Go (Golang) projects.

Rule of Clean Architecture by Uncle Bob

  • Independent of Frameworks. The architecture does not depend on the existence of some library of feature laden software. This allows you to use such frameworks as tools, rather than having to cram your system into their limited constraints.
  • Testable. The business rules can be tested without the UI, Database, Web Server, or any other external element.
  • Independent of UI. The UI can change easily, without changing the rest of the system. A Web UI could be replaced with a console UI, for example, without changing the business rules.
  • Independent of Database. You can swap out Oracle or SQL Server, for Mongo, BigTable, CouchDB, or something else. Your business rules are not bound to the database.
  • Independent of any external agency. In fact your business rules simply don’t know anything at all about the outside world.

More at https://8thlight.com/blog/uncle-bob/2012/08/13/the-clean-architecture.html

This project has 4 Domain layer :

  • Models Layer
  • Repository Layer
  • Usecase Layer
  • Delivery Layer

The diagram:

golang clean architecture

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.

How To Run This Project

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.

Run the Testing

$ make test

Run the Applications

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

Tools Used:

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-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