/go-study

Primary LanguageGoApache License 2.0Apache-2.0

Go Study Project

项目简介

这是一个基于Go语言的学习项目,使用Gin框架搭建,集成了MySQL和Redis数据库配置。

技术栈

  • Go 1.20+
  • Gin Web Framework
  • GORM ORM
  • Redis
  • MySQL

项目结构

go-study/
├── config/                # 配置管理
│   ├── init.go            # 初始化配置
│   ├── mysql.go           # MySQL数据库配置
│   ├── redis.go           # Redis配置
│   ├── setting.go         # 配置结构体
│   └── setting.yml        # 配置文件
│
├── entity/                # 数据模型
│   └── demo.go            # 示例数据模型
│
├── main.go                # 应用入口
└── go.mod                 # 依赖管理

环境准备

  1. 安装Go (推荐1.20+版本)
  2. 安装MySQL
  3. 安装Redis

配置

  1. 修改 config/setting.yml 配置数据库和Redis连接信息
database:
  host: 127.0.0.1
  port: 3306
  username: your_username
  password: your_password
  database: go-admin

redis:
  host: 127.0.0.1
  port: 6379
  db: 10
  password: your_redis_password

下载依赖

go mod tidy

运行项目

go run main.go