go-admin
基于Gin + Vue + Element UI & Arco Design & Ant Design 的前后端分离权限管理系统脚手架(包含了:多租户的支持,基础用户管理功能,jwt鉴权,代码生成器,RBAC资源控制,表单构建,定时任务等 )3分钟构建自己的中后台项目;项目文档》:https://www.go-admin.pro V2 Demo: https://vue2.go-admin.dev V3 Demo: https://vue3.go-admin.dev Antd PRO:https://antd.go-admin.pro
Top Related Projects
Gin is a HTTP web framework written in Go (Golang). It features a Martini-like API with much better performance -- up to 40 times faster. If you need smashing performance, get yourself some Gin.
beego is an open-source, high-performance web framework for the Go programming language.
High performance, minimalist Go web framework
⚡️ Express inspired web framework written in Go
The fastest HTTP/2 Go Web Framework. New, modern and easy to learn. Fast development with Code you control. Unbeatable cost-performance ratio :rocket:
Package gorilla/mux is a powerful HTTP router and URL matcher for building Go web servers with 🦍
Quick Overview
Go-Admin is a comprehensive backend management system framework built with Go. It provides a robust set of tools for rapid development of management interfaces, including user authentication, role-based access control, and a modular architecture for easy customization and extension.
Pros
- Rapid development of admin interfaces with pre-built components and templates
- Strong security features including role-based access control and JWT authentication
- Supports multiple databases (MySQL, PostgreSQL, SQLite)
- Modular architecture allows for easy customization and extension
Cons
- Steep learning curve for developers new to Go or complex backend frameworks
- Documentation is primarily in Chinese, which may be challenging for non-Chinese speakers
- Some reported issues with stability and bugs in earlier versions
- Limited community support compared to more established frameworks
Code Examples
- Creating a new API endpoint:
func (e *SysUser) GetPage(c *gin.Context) {
req := dto.SysUserGetPageReq{}
s := service.SysUser{}
err := e.MakeContext(c).
MakeOrm().
Bind(&req).
MakeService(&s.Service).
Errors
if err != nil {
e.Logger.Error(err)
e.Error(500, err, err.Error())
return
}
list := make([]models.SysUser, 0)
var count int64
err = s.GetPage(&req, &list, &count)
if err != nil {
e.Error(500, err, "查询失败")
return
}
e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
}
- Defining a new model:
type SysUser struct {
models.Model
Username string `json:"username" gorm:"size:64;uniqueIndex;not null"`
Password string `json:"-" gorm:"size:128;not null"`
NickName string `json:"nickName" gorm:"size:128"`
Phone string `json:"phone" gorm:"size:11"`
RoleId int `json:"roleId" gorm:"size:20"`
Salt string `json:"-" gorm:"size:255"`
Avatar string `json:"avatar" gorm:"size:255"`
Sex string `json:"sex" gorm:"size:255"`
Email string `json:"email" gorm:"size:128"`
DeptId int `json:"deptId" gorm:"size:20"`
PostId int `json:"postId" gorm:"size:20"`
Remark string `json:"remark" gorm:"size:255"`
Status string `json:"status" gorm:"size:4"`
LoginDate time.Time `json:"loginDate" gorm:"type:timestamp"`
DataScope string `json:"dataScope" gorm:"size:128"`
models.ControlBy
models.ModelTime
}
- Implementing role-based access control:
func (e *SysRole) GetPage(c *gin.Context) {
req := dto.SysRoleGetPageReq{}
s := service.SysRole{}
err := e.MakeContext(c).
MakeOrm().
Bind(&req).
MakeService(&s.Service).
Errors
if err != nil {
e.Logger.Error(err)
e.Error(500, err, err.Error())
return
}
list := make([]models.SysRole, 0)
var count int64
err = s.GetPage(&req, &list, &count)
if err != nil {
e.Error(500, err, "查询失败")
return
}
e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
}
Getting Started
Competitor Comparisons
Gin is a HTTP web framework written in Go (Golang). It features a Martini-like API with much better performance -- up to 40 times faster. If you need smashing performance, get yourself some Gin.
Pros of gin
- Lightweight and fast HTTP web framework
- Extensive middleware ecosystem and community support
- Simple and intuitive API for building web applications
Cons of gin
- Focused primarily on routing and middleware, lacking built-in admin features
- Requires additional setup for database integration and user management
Code Comparison
gin:
r := gin.Default()
r.GET("/ping", func(c *gin.Context) {
c.JSON(200, gin.H{"message": "pong"})
})
r.Run()
go-admin:
e := gin.Default()
var err error
cfg := config.Config{}
err = e.Use(admin.NewAdmin(&cfg))
if err != nil {
log.Fatal("gin-admin initialize error: ", err)
}
Key Differences
- go-admin provides a complete admin panel solution, while gin is a general-purpose web framework
- go-admin includes built-in user management and role-based access control
- gin offers more flexibility for custom implementations but requires more setup for admin functionality
- go-admin is better suited for rapid development of admin interfaces, while gin excels in building custom web applications
Use Cases
- Choose gin for building custom web applications with full control over the architecture
- Opt for go-admin when rapid development of admin panels with user management is required
beego is an open-source, high-performance web framework for the Go programming language.
Pros of Beego
- More mature and widely adopted framework with a larger community
- Comprehensive feature set including ORM, caching, and logging
- Better documentation and learning resources
Cons of Beego
- Heavier and more complex, potentially overkill for smaller projects
- Less flexible compared to more lightweight alternatives
- Steeper learning curve for developers new to the framework
Code Comparison
Beego routing example:
beego.Router("/", &controllers.MainController{})
beego.Router("/api/list", &controllers.APIController{}, "get:List")
beego.Run()
Go-Admin routing example:
r := gin.Default()
r.GET("/", controllers.Index)
r.GET("/api/list", controllers.APIList)
r.Run()
Both frameworks offer routing capabilities, but Beego uses a more structured approach with controller objects, while Go-Admin (based on Gin) uses a more lightweight function-based routing.
Beego provides a full-featured web framework with built-in components, making it suitable for large-scale applications. Go-Admin, on the other hand, is more focused on admin panel generation and management, offering a simpler setup for specific use cases.
Developers should consider project requirements, team expertise, and scalability needs when choosing between these frameworks.
High performance, minimalist Go web framework
Pros of Echo
- Lightweight and high-performance web framework
- Extensive middleware ecosystem and easy extensibility
- Strong community support and regular updates
Cons of Echo
- Less opinionated, requiring more setup for complex applications
- Fewer built-in admin features compared to Go-Admin
Code Comparison
Echo:
e := echo.New()
e.GET("/", func(c echo.Context) error {
return c.String(http.StatusOK, "Hello, World!")
})
e.Logger.Fatal(e.Start(":1323"))
Go-Admin:
e := gin.Default()
eng := engine.Default()
if err := eng.AddConfigFromYaml("./config.yaml").
AddGenerator("dashboard", GetDashboardGenerator).
Use(e); err != nil {
panic(err)
}
Summary
Echo is a lightweight, high-performance web framework with excellent middleware support, making it ideal for building APIs and microservices. Go-Admin, on the other hand, is more focused on providing a complete admin panel solution with built-in features for rapid development of admin interfaces.
Echo offers more flexibility and is less opinionated, allowing developers to structure their applications as they see fit. Go-Admin provides a more structured approach with pre-built admin functionalities, which can be advantageous for projects requiring quick setup of administrative interfaces.
The code comparison shows Echo's simplicity in setting up a basic route, while Go-Admin demonstrates its integration with Gin and configuration-based setup for admin panel generation.
⚡️ Express inspired web framework written in Go
Pros of Fiber
- Extremely fast and lightweight web framework
- Easy to use with Express-like API
- Extensive middleware ecosystem
Cons of Fiber
- Less comprehensive admin features out-of-the-box
- Requires more setup for full-fledged admin panels
Code Comparison
Fiber:
app := fiber.New()
app.Get("/", func(c *fiber.Ctx) error {
return c.SendString("Hello, World!")
})
app.Listen(":3000")
go-admin:
e := gin.Default()
cfg := config.Config{}
gin.SetMode(cfg.Settings.Mode)
go_admin.Init(e, &cfg)
e.Run(cfg.Settings.Address)
Key Differences
- Fiber focuses on high-performance web applications
- go-admin provides a complete admin panel solution
- Fiber offers more flexibility for custom implementations
- go-admin includes built-in user management and permissions
Use Cases
- Fiber: Ideal for building high-performance APIs and microservices
- go-admin: Better suited for quickly setting up admin interfaces and dashboards
Community and Support
- Fiber: Large community, frequent updates, extensive documentation
- go-admin: Smaller community, focused on admin panel use cases
Performance
- Fiber: Known for exceptional speed and low memory footprint
- go-admin: Optimized for admin panel operations, may have higher overhead
The fastest HTTP/2 Go Web Framework. New, modern and easy to learn. Fast development with Code you control. Unbeatable cost-performance ratio :rocket:
Pros of Iris
- More comprehensive web framework with built-in features like websockets, MVC, and dependency injection
- Higher performance and lower memory usage in benchmarks
- Extensive documentation and active community support
Cons of Iris
- Steeper learning curve due to more complex API and features
- Less focused on admin panel functionality compared to Go-Admin
- Some controversy in the past regarding versioning and licensing practices
Code Comparison
Iris:
app := iris.New()
app.Get("/", func(ctx iris.Context) {
ctx.JSON(iris.Map{"message": "Hello, World!"})
})
app.Listen(":8080")
Go-Admin:
e := gin.Default()
cfg := config.Config{}
ga := initialize.Init(&cfg)
ga.Middleware(e)
e.Run(":8080")
Summary
Iris is a more feature-rich and performance-oriented web framework, while Go-Admin focuses specifically on creating admin panels. Iris offers a wider range of built-in functionalities, making it suitable for various web application needs. Go-Admin, on the other hand, provides a streamlined solution for quickly setting up admin interfaces. The choice between the two depends on the specific requirements of your project and whether you need a general-purpose web framework or a specialized admin panel solution.
Package gorilla/mux is a powerful HTTP router and URL matcher for building Go web servers with 🦍
Pros of mux
- Lightweight and focused: mux is a simple, efficient HTTP router and URL matcher
- Highly flexible: Allows for custom middleware and fine-grained route control
- Well-established: Widely used and battle-tested in production environments
Cons of mux
- Limited scope: Doesn't provide a full-featured admin panel or user management system
- Requires more setup: Developers need to implement additional features for a complete admin solution
- Less opinionated: May require more decision-making for project structure and best practices
Code Comparison
mux:
r := mux.NewRouter()
r.HandleFunc("/api/users", GetUsersHandler).Methods("GET")
r.HandleFunc("/api/users/{id}", GetUserHandler).Methods("GET")
http.ListenAndServe(":8080", r)
go-admin:
e := gin.Default()
authMiddleware, err := middleware.AuthInit()
RegisterBaseRouter(e, authMiddleware)
RegisterSystemRouter(e, authMiddleware)
e.Run(":8080")
Summary
mux is a lightweight HTTP router focusing on URL matching and routing, while go-admin is a more comprehensive admin panel solution. mux offers flexibility and simplicity but requires additional work for a complete admin system. go-admin provides a ready-to-use admin panel with built-in features, but may be less flexible for custom routing needs.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
go-admin
English | ç®ä½ä¸æ
The front-end and back-end separation authority management system based on Gin + Vue + Element UI OR Arco Design is extremely simple to initialize the system. You only need to modify the database connection in the configuration file. The system supports multi-instruction operations. Migration instructions can make it easier to initialize database information. Service instructions It's easy to start the api service.
ð¬ Online Demo
Element UI vue demoï¼https://vue2.go-admin.dev
è´¦å· / å¯ç ï¼ admin / 123456
Arco Design vue3 demoï¼https://vue3.go-admin.dev
è´¦å· / å¯ç ï¼ admin / 123456
antd demoï¼https://antd.go-admin.pro
è´¦å· / å¯ç ï¼ admin / 123456
⨠Feature
-
Follow RESTful API design specifications
-
Based on the GIN WEB API framework, it provides rich middleware support (user authentication, cross-domain, access log, tracking ID, etc.)
-
RBAC access control model based on Casbin
-
JWT authentication
-
Support Swagger documents (based on swaggo)
-
Database storage based on GORM, which can expand multiple types of databases
-
Simple model mapping of configuration files to quickly get the desired configuration
-
Code generation tool
-
Form builder
-
Multi-command mode
-
TODO: unit test
ð Internal
- User management: The user is the system operator, this function mainly completes the system user configuration.
- Department management: configure the system organization (company, department, group), and display the tree structure to support data permissions.
- Position management: configure the positions of system users.
- Menu management: configure the system menu, operation authority, button authority identification, interface authority, etc.
- Role management: Role menu permission assignment and role setting are divided into data scope permissions by organization.
- Dictionary management: Maintain some relatively fixed data frequently used in the system.
- Parameter management: dynamically configure common parameters for the system.
- Operation log: system normal operation log record and query; system abnormal information log record and query.
- Login log: The system login log record query contains login exceptions.
- Interface documentation: Automatically generate related api interface documents according to the business code.
- Code generation: According to the data table structure, generate the corresponding addition, deletion, modification, and check corresponding business, and the whole process of visual operation, so that the basic business can be implemented with zero code.
- Form construction: Customize the page style, drag and drop to realize the page layout.
- Service monitoring: View the basic information of some servers.
- Content management: demo function, including classification management and content management. You can refer to the easy to use quick start.
Ready to work
You need to install locally [go] [gin] node å git
At the same time, a series of tutorials including videos and documents are provided. How to complete the downloading to the proficient use, it is strongly recommended that you read these tutorials before you practice this project! ! !
Easily implement go-admin to write the first application-documentation tutorial
Step 1 - basic content introduction
Step 2 - Practical application - writing database operations
Teach you from getting started to giving up-video tutorial
Easily implement business using build tools
v1.1.0 version code generation tool-free your hands [Advanced]
Explanation of multi-command startup mode and IDE configuration
Configuration instructions for go-admin menu [Must see]
How to configure menu information and interface information [Must see]
go-admin permission configuration instructions [Must see]
Instructions for use of go-admin data permissions [Must see]
If you have any questions, please read the above-mentioned usage documents and articles first. If you are not satisfied, welcome to issue and pr. Video tutorials and documents are being updated continuously.
ð¦ Local development
Environmental requirements
go 1.18
nodejs: v14.16.0
npm: 6.14.11
Development directory creation
# Create a development directory
mkdir goadmin
cd goadmin
Get the code
Important note: the two projects must be placed in the same folder;
# Get backend code
git clone https://github.com/go-admin-team/go-admin.git
# Get the front-end code
git clone https://github.com/go-admin-team/go-admin-ui.git
Startup instructions
Server startup instructions
# Enter the go-admin backend project
cd ./go-admin
# Update dependencies
go mod tidy
# Compile the project
go build
# Change setting
# File path go-admin/config/settings.yml
vi ./config/settings.yml
# 1. Modify the database information in the configuration file
# Note: The corresponding configuration data under settings.database
# 2. Confirm the log path
:::tip â ï¸Note that this problem will occur if CGO is not installed in the windows10+ environment;
E:\go-admin>go build
# github.com/mattn/go-sqlite3
cgo: exec /missing-cc: exec: "/missing-cc": file does not exist
or
D:\Code\go-admin>go build
# github.com/mattn/go-sqlite3
cgo: exec gcc: exec: "gcc": executable file not found in %PATH%
Solve the cgo problem and enter
:::
Initialize the database, and start the service
# The first configuration needs to initialize the database resource information
# Use under macOS or linux
$ ./go-admin migrate -c config/settings.dev.yml
# â ï¸Note: Use under windows
$ go-admin.exe migrate -c config/settings.dev.yml
# Start the project, you can also use the IDE for debugging
# Use under macOS or linux
$ ./go-admin server -c config/settings.yml
# â ï¸Note: Use under windows
$ go-admin.exe server -c config/settings.yml
Use docker to compile and start
# Compile the image
docker build -t go-admin .
# Start the container, the first go-admin is the container name, and the second go-admin is the image name
# -v Mapping configuration file Local path: container path
docker run --name go-admin -p 8000:8000 -v /config/settings.yml:/config/settings.yml -d go-admin-server
Generation Document
go generate
Cross compile
# windows
env GOOS=windows GOARCH=amd64 go build main.go
# or
# linux
env GOOS=linux GOARCH=amd64 go build main.go
UI interactive terminal startup instructions
# Installation dependencies
npm install # or cnpm install
# Start service
npm run dev
ð¨ Interactive
wenjianzhang | |||
Wechatå ¬ä¼å·ð¥ð¥ð¥ | bilibilið¥ð¥ð¥ |
ð Contributors
JetBrains open source certificate support
The go-admin
project has always been developed in the GoLand integrated development environment under JetBrains, based on the free JetBrains Open Source license(s) genuine free license. I would like to express my gratitude.
ð¤ Thanks
- ant-design
- ant-design-pro
- arco-design
- arco-design-pro
- gin
- casbin
- spf13/viper
- gorm
- gin-swagger
- jwt-go
- vue-element-admin
- ruoyi-vue
- form-generator
ð¤ Sponsor Us
If you think this project helped you, you can buy a glass of juice for the author to show encouragement :tropical_drink:
ð¤ Link
ð License
Copyright (c) 2022 wenjianzhang
Top Related Projects
Gin is a HTTP web framework written in Go (Golang). It features a Martini-like API with much better performance -- up to 40 times faster. If you need smashing performance, get yourself some Gin.
beego is an open-source, high-performance web framework for the Go programming language.
High performance, minimalist Go web framework
⚡️ Express inspired web framework written in Go
The fastest HTTP/2 Go Web Framework. New, modern and easy to learn. Fast development with Code you control. Unbeatable cost-performance ratio :rocket:
Package gorilla/mux is a powerful HTTP router and URL matcher for building Go web servers with 🦍
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot