Skip to content

template project for gone, using mysql for database

Notifications You must be signed in to change notification settings

gone-io/template-v2-web-mysql

 
 

Repository files navigation

English  |  中文

Gone Web MySQL Template Project

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.

Project Features

  • 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

Tech Stack

  • Gone - Go application framework based on dependency injection
  • Gin - Web framework
  • Xorm - ORM framework
  • MySQL - Database
  • Docker - Containerized deployment

Directory Structure

.
├── 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

Quick Start

Prerequisites

  • Go 1.24 or higher
  • MySQL 8.0 or higher
  • Docker and Docker Compose (optional, for containerized deployment)

Local Development

  1. Install dependencies
go mod download
  1. 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
  1. Run the project
make run

The service will start at http://localhost:8080

Docker Deployment

  1. Build Docker image
make build-docker
  1. Start service
docker compose up -d

The service will start at http://localhost:8080, and MySQL database will be available at localhost:3306

Configuration Guide

Project configuration file is located at config/default.properties, main configuration items include:

  • server.port - Service port, default is 8080
  • server.mode - Gin service mode, options are debug, test, release, default is release
  • server.health-check - Health check path, default is /api/health-check
  • db.host - Database host
  • db.port - Database port
  • db.name - Database name
  • db.username - Database username
  • db.password - Database password

Development Guide

Adding New APIs

  1. Define interface in internal/interface
  2. Implement interface in internal/module
  3. Create controller in internal/controller
  4. Register route in internal/router

Generating Mocks

The project uses mockgen to generate mock code:

go generate ./...

About

template project for gone, using mysql for database

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 88.6%
  • Dockerfile 9.0%
  • Makefile 2.4%