Skip to content

Commit

Permalink
chore: add structure
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjayheaven committed Jan 18, 2024
1 parent c437422 commit d83ec61
Show file tree
Hide file tree
Showing 14 changed files with 208 additions and 7 deletions.
7 changes: 7 additions & 0 deletions docs/go-gin-boilerplate/docs/guide/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"label": "指南",
"position": 3,
"link": {
"type": "generated-index"
}
}
7 changes: 7 additions & 0 deletions docs/go-gin-boilerplate/docs/guide/config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
sidebar_position: 0.9
---

# 配置


5 changes: 5 additions & 0 deletions docs/go-gin-boilerplate/docs/guide/controller.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
sidebar_position: 2
---

# 控制器
5 changes: 5 additions & 0 deletions docs/go-gin-boilerplate/docs/guide/error.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
sidebar_position: 6
---

# 异常处理
5 changes: 5 additions & 0 deletions docs/go-gin-boilerplate/docs/guide/logger.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
sidebar_position: 5
---

# 日志
5 changes: 5 additions & 0 deletions docs/go-gin-boilerplate/docs/guide/middleware.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
sidebar_position: 4
---

# 中间件
5 changes: 5 additions & 0 deletions docs/go-gin-boilerplate/docs/guide/model.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
sidebar_position: 3.1
---

# 模型
7 changes: 7 additions & 0 deletions docs/go-gin-boilerplate/docs/guide/router.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
sidebar_position: 1
---

# 路由


5 changes: 5 additions & 0 deletions docs/go-gin-boilerplate/docs/guide/service.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
sidebar_position: 3
---

# 服务
2 changes: 1 addition & 1 deletion docs/go-gin-boilerplate/docs/start/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
sidebar_position: 4
---

# 部署
# 正式部署

多种方式部署你的项目
34 changes: 32 additions & 2 deletions docs/go-gin-boilerplate/docs/start/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
sidebar_position: 3
---

# 运行
# 运行项目

在本地运行项目

## 使用 air 运行项目【推荐】
## 使用 air 运行项目【开发环境推荐】

> [Air](https://github.com/cosmtrek/air) 是为 Go 应用开发设计的另外一个热重载的命令行工具。只需在你的项目根目录下输入 air,然后把它放在一边,专注于你的代码即可
在项目根目录中,打开终端,执行命令

```sh
air
Expand Down Expand Up @@ -64,10 +68,36 @@ keep_scroll = true

## 使用 go run 运行项目

在项目根目录中,打开终端,执行命令

```sh
go run main.go server
```

## 打包后执行 【生产环境推荐】

### 打包程序

在终端执行命令

```sh
make build
```

或者

```sh
go build -o build/ggb main.go
```

### 运行程序

打包后的程序路径为 build/ggb, 在终端执行命令

```sh
./build/ggb server
```

## 查看更多命令

```sh
Expand Down
102 changes: 102 additions & 0 deletions docs/go-gin-boilerplate/docs/start/structure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
sidebar_position: 0.1
---

# 目录结构

展示当前项目的目录结构,各部分的作用。

项目目录结构完全遵守 [project-layout](https://github.com/golang-standards/project-layout) 规范,结构清晰,便于扩展和维护。

> `project-layout`:
> 这是 Go 应用程序项目的基本布局。它不是核心 Go 开发团队定义的官方标准;然而,它是 Go 生态系统中一组常见的老项目和新项目的布局模式。其中一些模式比其他模式更受欢迎。它还具有许多小的增强,以及对任何足够大的实际应用程序通用的几个支持目录。
```sh

.
├── .github ---------------------------- GitHub 相关配置
│   └── workflows ------------------------ GitHub Actions 配置
│   ├── deploy.yml --------------------- 部署到github pages
│   └── go.yml ------------------------- Go
├── api -------------------------------- API 文档
│   └── swagger -------------------------- swagger 接口文档
│   ├── docs.go
│   ├── swagger.json
│   └── swagger.yaml
├── assets ----------------------------- 静态资源
│   ├── golang.png
│   └── x.png
├── build ------------------------------ 构建目录
├── cmd -------------------------------- 命令行工具
│   ├── root.go -------------------------- 命令行工具入口
│   ├── server.go ------------------------ 服务命令
│   └── version.go ----------------------- 版本命令
├── configs ---------------------------- 配置文件
│   ├── config.example.yaml -------------- 配置文件示例
│   ├── config.go ------------------------ 配置文件解析
│   ├── jwt.go --------------------------- JWT 配置
│   ├── mongo.go ------------------------- MongoDB 配置
│   ├── mysql.go ------------------------- MySQL 配置
│   ├── redis.go ------------------------- Redis 配置
│   └── server.go ------------------------ 项目服务配置
├── deployments ------------------------ 部署相关
│   ├── docker-compose.yml --------------- Docker Compose 配置
│   └── restart-server.sh ---------------- 重启服务脚本
├── docs ------------------------------- 文档
├── githooks --------------------------- Git 钩子
│   ├── commit-msg ----------------------- Git 提交信息钩子
│   └── pre-commit ----------------------- Git 提交前钩子
├── internal --------------------------- 内部代码
│   ├── controllers ---------------------- 控制器
│   │   ├── example.go --------------------- 示例控制器
│   │   ├── public.go ---------------------- 公共控制器
│   │   └── user.go ------------------------ 用户控制器
│   ├── middlewares -------------------- 中间件
│   │   ├── cors.go ---------------------- 跨域中间件
│   │   ├── errorHandle.go --------------- 错误处理中间件
│   │   ├── jwt.go ----------------------- JWT 中间件
│   │   ├── limit.go --------------------- 限流中间件
│   │   └── middleware.go ---------------- 中间件入口
│   ├── models ------------------------- 模型
│   │   ├── example.go ------------------- 示例模型
│   │   ├── model.go --------------------- 模型入口
│   │   └── user.go ---------------------- 用户模型
│   ├── pkg ---------------------------- 内部代码共享包
│   │   ├── logger ----------------------- 日志
│   │   │   ├── logger.go ------------------ 日志入口
│   │   │   ├── logrus.go ------------------ logrus 日志
│   │   │   └── zap.go ---------------------- zap 日志
│   │   ├── mongo ------------------------ MongoDB 包
│   │   │   └── mongo.go --------------------- MongoDB 包入口
│   │   ├── mysql ------------------------ MySQL 包
│   │   │   └── mysql.go --------------------- MySQL 包入口
│   │   ├── redis ------------------------ Redis 包
│   │   │   └── redis.go ------------------- Redis 包入口
│   │   ├── response --------------------- 响应包
│   │   │   └── response.go ---------------- 响应包入口
│   │   └── utils ------------------------ 工具包
│   │   └── jwt.go --------------------- jwt 工具包
│   ├── router ------------------------- 路由
│   │   ├── example.go ------------------- 示例路由
│   │   ├── public.go -------------------- 公共路由
│   │   ├── router.go -------------------- 路由入口
│   │   └── user.go ---------------------- 用户路由
│   └── services ----------------------- 服务
│   ├── example.go ------------------- 示例服务
│   ├── service.go ------------------- 服务入口
│   └── user.go ---------------------- 用户服务
├── scripts ---------------------------- 脚本
│   ├── build.sh ------------------------- 构建脚本
│   ├── clean.sh ------------------------- 清理脚本
│   └── lint.sh -------------------------- 代码检查脚本
├── test ------------------------------- 测试目录
├── .air.toml -------------------------- air 配置
├── .gitignore ------------------------- git 忽略文件
├── LICENSE ---------------------------- 开源协议
├── Makefile --------------------------- Makefile
├── README.md -------------------------- 项目说明
├── README_en.md ----------------------- 项目说明(英文版)
├── go.mod ----------------------------- go mod
├── go.sum ----------------------------- go mod
└── main.go ---------------------------- 项目入口
```
7 changes: 4 additions & 3 deletions docs/go-gin-boilerplate/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const config: Config = {
url: "https://sanjayheaven.github.io",
// Set the /<baseUrl>/ pathname under which your site is served
// For GitHub pages deployment, it is often '/<projectName>/'
baseUrl: "/",
baseUrl: "/go-gin-boilerplate/",

// GitHub pages deployment config.
// If you aren't using GitHub pages, you don't need these.
Expand Down Expand Up @@ -69,13 +69,14 @@ const config: Config = {
type: "docSidebar",
sidebarId: "tutorialSidebar",
position: "left",
label: "文档",
label: "使用文档",
},
// { to: "/blog", label: "Blog", position: "left" },
{
href: "https://github.com/sanjayheaven/go-gin-boilerplate",
label: "GitHub",
position: "right",
className: "header-github-link",
"aria-label": "GitHub repository",
},
],
},
Expand Down
19 changes: 18 additions & 1 deletion docs/go-gin-boilerplate/src/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
--docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.1);
} */
:root {
--ifm-color-primary: #6ad7e5;
--ifm-color-primary: #0890f7;
/* --ifm-color-primary-dark: #6ad7e5;
--ifm-color-primary-darker: #277148;
--ifm-color-primary-darkest: #205d3b;
Expand All @@ -41,3 +41,20 @@
--ifm-color-primary-lightest: #4fddbf;
--docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.3);
}

.header-github-link:hover {
opacity: 0.6;
}

.header-github-link:before {
content: "";
width: 24px;
height: 24px;
display: flex;
background: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12'/%3E%3C/svg%3E");
}

html[data-theme="dark"] .header-github-link:before {
background: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='white' d='M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12'/%3E%3C/svg%3E")
no-repeat;
}

0 comments on commit d83ec61

Please sign in to comment.