https://github.com/birjemin/gin-structure
gin简单的项目结构
https://github.com/birjemin/gin-structure
gin golang
Last synced: 2 months ago
JSON representation
gin简单的项目结构
- Host: GitHub
- URL: https://github.com/birjemin/gin-structure
- Owner: Birjemin
- Created: 2019-12-10T13:25:50.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-12-12T06:05:33.000Z (almost 6 years ago)
- Last Synced: 2025-07-04T06:14:10.935Z (3 months ago)
- Topics: gin, golang
- Language: Go
- Size: 26.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## 简单的gin项目结构
其实就是别人的拿过来改一下适合自己的风格### 改动点
* 加了一个`--port`选项,方便加载配置和指定端口
* 加了一个平滑关闭(graceful shutdown)
* 加了mod方式解决依赖```
// 运行
go run main.go --port=8081
// 编译
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build main.go
```### GRPC
```
brew install protobuf
protoc --version
protoc -I . --go_out=plugins=grpc:. grpc/pb/hello.proto
``````
go run grpc/server.go
```### 部署方式
参考:[https://beego.me/docs/deploy/beego.md](https://beego.me/docs/deploy/beego.md)
> 请注意app.ini配置文件的位置!!!(比如supervisor中的directory配置)
* 独立部署
``
nohup /data/www/main --port=8081 >> /data/logs/main_8081.log 2>&1 &
``* Supervisor部署
```
directory=/data/www/Go/src/gin-structure
command=/data/www/main --port=8081
numprocs=1
autostart=true
autorestart=true
startretries=3
user=www
redirect_stderr=true
stdout_logfile=/data/logs/supervisor_xxx_8081.log
```* Nginx负载均衡
...