This is a pure API service with Gin.
参考链接和项目, 灵感启发来源, 范本
- Project Layout
- go-gin-example
gin-vue-admin- A simple Gin Gonic REST API using MongoDB
- Example of Microservices in Go with Docker, Kubernetes and MongoDB
- swag
- gin-swagger
- zap
- cobra
- viper
gorm- mongo
mysql- redis
- godotenv # load .env files
.
├─ api # API Protocols, Definitions and Middleware
├─ bin # Compiled Binaries
├─ cmd # Application Startups, contains 'main' functions
│ └─ server # The name of the microservice
│ └─ main.go
├─ internal # Private Application and Library Code
├─ pkg # Public library code (e.g., models, utilities)
├─ web # Web UI
├─ scripts # Scripts for tooling
├─ .gitignore # Specifies intentionally untracked files to ignore
├─ Dockerfile # Instructions to create a Docker image
├─ go.mod # Go Modules dependencies
├─ go.sum # Contains the expected cryptographic checksums of the content of specific module versions
└─ README.md # Project Overview and Instructions
- keep both in the same directory, just like go-gin-example
# build docker image for current demo-gin
docker build -t demo-gin .
docker run --rm -p 8000:8000 --name demo-gin -it demo-gin
Add notations for main function and each handle-func, then use swag init
to generating docs. Please Notice that register swagger router to main router
See GitHub project demo-gin
Note: the link above may be unusable because it's a private project.