English | 中文
This is a web application template project based on the Gone framework, integrated with MySQL database support, which can serve as a starting point for developing web applications.
- Built on the Gone framework using dependency injection design pattern
- Integrated MySQL database support
- Provides complete project structure and code organization
- Supports Docker deployment
- Includes user management example code
- Gone - Go application framework based on dependency injection
- Gin - Web framework
- Xorm - ORM framework
- MySQL - Database
- Docker - Containerized deployment
.
├── cmd # Application entry
│ └── server # Server entry
├── config # Configuration files
├── internal # Internal code
│ ├── controller # Controllers
│ ├── interface # Interface definitions
│ ├── module # Module implementations
│ ├── pkg # Utility packages
│ └── router # Route definitions
├── scripts # Script files
│ └── mysql # MySQL initialization scripts
└── tests # Test files
└── api # API tests
- Go 1.24 or higher
- MySQL 8.0 or higher
- Docker and Docker Compose (optional, for containerized deployment)
- Install dependencies
go mod download
- Configure database
Edit config/default.properties
file, set database connection information:
db.host=localhost
db.port=3306
db.name=demo
db.username=root
db.password=123456
- Run the project
make run
The service will start at http://localhost:8080
- Build Docker image
make build-docker
- Start service
docker compose up -d
The service will start at http://localhost:8080, and MySQL database will be available at localhost:3306
Project configuration file is located at config/default.properties
, main configuration items include:
server.port
- Service port, default is 8080server.mode
- Gin service mode, options are debug, test, release, default is releaseserver.health-check
- Health check path, default is /api/health-checkdb.host
- Database hostdb.port
- Database portdb.name
- Database namedb.username
- Database usernamedb.password
- Database password
- Define interface in
internal/interface
- Implement interface in
internal/module
- Create controller in
internal/controller
- Register route in
internal/router
The project uses mockgen to generate mock code:
go generate ./...