Large Web project structure of Golang Gin framework (personal suggestion)

The Gin framework does not provide a standard large-scale project structure, but there are some common best practices that can be referred to. The following is a common large-scale web project structure based on the Gin framework:

├── config
│  ├── config.go
│  └── settings.go
├── controllers
│  ├── auth.go
│  └── user.go
├── db
│  ├── mysql.go
│  ├── redis.go
│  └── mongo.go
├── models
│  ├── user.go
│  └── artist.go
├── middleware
│  ├── auth.go
│  └── logger.go
├── services
│  └── user.go
├── utils
│  ├── auth.go
│  └── helper.go
├── main.go
└── README.md

Among them, config stores the configuration information of the project; controllers store the controller code, and each controller is responsible for processing a set of related HTTP requests; db stores the code related to the database; models stores the definition of the data model; middleware stores the middleware related Code, such as authority control, log records, etc.; services store service layer code, responsible for processing core business logic; utils store tool functions and auxiliary methods; main.go is the entry file of the application, including routing initialization and web service startup .

The above is a general Gin project structure, but in actual projects, appropriate adjustments and modifications should be made according to specific situations.

Guess you like

Origin blog.csdn.net/canduecho/article/details/130934036