# go-web **Repository Path**: KlysNcheJs/go-web ## Basic Information - **Project Name**: go-web - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-06-18 - **Last Updated**: 2025-07-24 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README gin web项目架构: 基于MVC模式,将应用程序分为模型、视图和控制器三个部分 使用Gin框架作为HTTP服务器和路由器 使用Gorm作为ORM框架 使用Viper作为配置管理工具 使用Logrus作为日志记录工具 gin项目结构: ├── config │ ├── config.go │ └── config.yaml ├── controller │ └── user_controller.go ├── dao │ └── user_dao.go ├── db │ └── db.go ├── middleware │ └── auth.go ├── model │ └── user.go ├── router │ └── router.go ├── service │ └── user_service.go ├── util │ └── util.go ├── main.go └── README.md config:存放配置文件和配置管理代码 controller:存放控制器代码 dao:存放数据访问对象代码 db:存放数据库连接代码 middleware:存放中间件代码 model:存放模型代码 router:存放路由器代码 service:存放服务代码 util:存放工具函数代码 main.go:入口文件 README.md:项目说明文件 # Gin MVC Demo A demo project using Gin and GORM with MVC architecture. ## Features - MVC architecture - Configuration management with Viper - Logging with Logrus - Database operations with GORM - Layered architecture (Controller -> Service -> DAO -> Model) ## Project Structure ``` gin-mvc-demo/ ├── config/ # Configuration files and code │ ├── config.go │ └── config.yaml ├── controller/ # Controllers │ └── user_controller.go ├── dao/ # Data Access Objects │ └── user_dao.go ├── db/ # Database connection │ └── db.go ├── middleware/ # Middlewares │ └── auth.go ├── model/ # Models │ └── user.go ├── router/ # Router setup │ └── router.go ├── service/ # Business logic │ └── user_service.go ├── util/ # Utility functions │ └── util.go ├── main.go # Entry point └── README.md # Project documentation ``` ## API Endpoints - `POST /api/users` - Create a new user - `GET /api/users` - List users with pagination - `GET /api/users/:id` - Get user by ID - `PUT /api/users/:id` - Update user - `DELETE /api/users/:id` - Delete user ## How to Run 1. Install dependencies: ```bash go mod tidy ``` 2. Update database configuration in `config/config.yaml` 3. Run the application: ```bash go run main.go ``` 4. The server will start on `http://localhost:8080`