go-backend-clean-architecture

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Go Clean Architecture

Go Clean Architecture

A Go backend with Gin, MongoDB, JWT authentication, and Docker support following Clean Architecture principles.
这是一个遵循Clean Architecture原则,基于Gin、MongoDB、JWT认证并支持Docker的Go后端项目。

Tech Stack

技术栈

  • Framework: Gin
  • Language: Go
  • Database: MongoDB
  • Auth: JWT
  • Architecture: Clean Architecture
  • 框架: Gin
  • 语言: Go
  • 数据库: MongoDB
  • 认证: JWT
  • 架构: Clean Architecture

Prerequisites

前提条件

  • Go 1.21+
  • MongoDB
  • Docker (optional)
  • Go 1.21+
  • MongoDB
  • Docker(可选)

Setup

安装步骤

1. Clone the Template

1. 克隆模板

bash
git clone --depth 1 https://github.com/amitshekhariitbhu/go-backend-clean-architecture.git .
If the directory is not empty:
bash
git clone --depth 1 https://github.com/amitshekhariitbhu/go-backend-clean-architecture.git _temp_template
mv _temp_template/* _temp_template/.* . 2>/dev/null || true
rm -rf _temp_template
bash
git clone --depth 1 https://github.com/amitshekhariitbhu/go-backend-clean-architecture.git .
如果目录非空:
bash
git clone --depth 1 https://github.com/amitshekhariitbhu/go-backend-clean-architecture.git _temp_template
mv _temp_template/* _temp_template/.* . 2>/dev/null || true
rm -rf _temp_template

2. Remove Git History (Optional)

2. 移除Git历史记录(可选)

bash
rm -rf .git
git init
bash
rm -rf .git
git init

3. Install Dependencies

3. 安装依赖

bash
go mod download
bash
go mod download

4. Setup Environment

4. 配置环境

Configure MongoDB connection and JWT secret.
配置MongoDB连接和JWT密钥。

Build

构建

bash
go build -o app ./cmd/main.go
bash
go build -o app ./cmd/main.go

Development

开发运行

bash
go run ./cmd/main.go
bash
go run ./cmd/main.go