Back to Go Admin

go-admin

README.zh-TW.md

2.6.017.8 KB
Original Source

go-admin

English | 简体中文 | 繁體中文 | 日本語

基於 Gin + Vue + Element UI OR Arco Design OR Ant Design 的前後端分離權限管理系統。系統初始化極為簡單,只需在設定檔中修改資料庫連線資訊即可。系統支援多指令操作:遷移指令讓資料庫初始化變得更簡單,服務指令則能輕鬆啟動 API 服務。

線上文件

前端專案

影片教學

🎬 線上體驗

Element Plus vue3 體驗:https://vue.go-admin.pro

⚠️⚠️⚠️ 帳號 / 密碼: admin / 123456

antd 體驗(go-admin-pro):https://antd.go-admin.pro

⚠️⚠️⚠️ 帳號 / 密碼: admin / 123456

✨ 特性

  • 遵循 RESTful API 設計規範

  • 基於 GIN WEB API 框架,提供豐富的中介軟體支援(使用者認證、跨域、存取日誌、追蹤 ID 等)

  • 基於 Casbin 的 RBAC 存取控制模型

  • JWT 認證

  • 支援 Swagger 文件(基於 swaggo)

  • 基於 GORM 的資料庫儲存,可擴充多種類型資料庫

  • 設定檔簡單的模型映射,快速取得所需設定

  • 程式碼產生工具

  • 表單建構工具

  • 多指令模式

  • 多租戶的支援

  • TODO: 單元測試

🎁 內建

  1. 多租戶:系統預設支援多租戶,按資料庫分離,一個資料庫一個租戶。
  2. 使用者管理:使用者是系統操作者,該功能主要完成系統使用者設定。
  3. 部門管理:設定系統組織架構(公司、部門、小組),以樹狀結構呈現並支援資料權限。
  4. 職位管理:設定系統使用者所擔任的職務。
  5. 選單管理:設定系統選單、操作權限、按鈕權限標識、介面權限等。
  6. 角色管理:角色選單權限分配、設定角色按機構進行資料範圍權限劃分。
  7. 字典管理:對系統中經常使用且較為固定的資料進行維護。
  8. 參數管理:對系統動態設定常用參數。
  9. 操作日誌:系統正常操作的日誌記錄與查詢;系統異常資訊的日誌記錄與查詢。
  10. 登入日誌:系統登入日誌記錄查詢,包含登入異常。
  11. 介面文件:根據業務程式碼自動產生相關的 API 介面文件。
  12. 程式碼產生:根據資料表結構產生對應的增刪改查業務,全程視覺化操作,讓基本業務可以零程式碼實現。
  13. 表單建構:自訂頁面樣式,拖拉放實現頁面佈局。
  14. 服務監控:檢視伺服器的基本資訊。
  15. 內容管理:demo 功能,下設分類管理、內容管理,可參考使用以快速入門。
  16. 排程任務:自動化任務,目前支援介面呼叫與函式呼叫。

準備工作

你需要在本機安裝 [go] [gin] nodegit

同時配套了系列教學(含影片與文件),說明如何從下載到熟練使用。強烈建議先看完這些教學再來實作本專案!!!

輕鬆用 go-admin 寫出第一個應用 - 文件教學

步驟一 - 基礎內容介紹

步驟二 - 實際應用 - 撰寫增刪改查

手把手教你從入門到放棄 - 影片教學

如何啟動 go-admin

使用產生工具輕鬆實現業務

v1.1.0 版本程式碼產生工具 - 釋放雙手 [進階]

多指令啟動方式講解以及 IDE 設定

go-admin 選單的設定說明 [必看]

如何設定選單資訊以及介面資訊 [必看]

go-admin 權限設定使用說明 [必看]

go-admin 資料權限使用說明 [必看]

如有問題請先參閱上述文件與文章,若仍無法解決,歡迎提出 issue 與 pr。影片教學與文件持續更新中

📦 本機開發

環境需求

go 1.26.5

node 版本: v22+(建議 v24 LTS)

套件管理器: pnpm v9+(UI 專案使用 pnpm)

建立開發目錄

bash

# 建立開發目錄
mkdir goadmin
cd goadmin

取得程式碼

重點注意:兩個專案必須放在同一資料夾下;

bash
# 取得後端程式碼
git clone https://github.com/go-admin-team/go-admin.git

# 取得前端程式碼
git clone https://github.com/go-admin-team/go-admin-ui.git

啟動說明

伺服器端啟動說明

bash
# 進入 go-admin 後端專案
cd ./go-admin

# 更新整理相依套件
go mod tidy

# 編譯專案
go build

# 修改設定
# 檔案路徑  go-admin/config/settings.yml
vi ./config/settings.yml

# 1. 在設定檔中修改資料庫資訊
# 注意: settings.database 下對應的設定資料
# 2. 確認 log 路徑

⚠️注意 在 Windows 環境若未安裝 CGO,會出現這個問題;

bash
E:\go-admin>go build
# github.com/mattn/go-sqlite3
cgo: exec /missing-cc: exec: "/missing-cc": file does not exist

or

bash
D:\Code\go-admin>go build
# github.com/mattn/go-sqlite3
cgo: exec gcc: exec: "gcc": executable file not found in %PATH%

解決 cgo 問題請進入

初始化資料庫,以及服務啟動

bash
# 首次設定需要初始化資料庫資源資訊
# macOS or linux 下使用
$ ./go-admin migrate -c config/settings.dev.yml

# ⚠️注意:windows 下使用
$ go-admin.exe migrate -c config/settings.dev.yml


# 啟動專案,也可以用 IDE 進行除錯
# macOS or linux 下使用
$ ./go-admin server -c config/settings.yml


# ⚠️注意:windows 下使用
$ go-admin.exe server -c config/settings.yml

sys_api 表的資料如何新增

在專案啟動時,使用 -a true 系統會自動新增缺少的介面資料

bash
./go-admin server -c config/settings.yml -a true

使用 docker 編譯啟動

shell
# 編譯映像檔
docker build -t go-admin .

# 啟動容器,第一個 go-admin 是容器名稱,第二個 go-admin 是映像檔名稱
# -v 映射設定檔 本機路徑:容器路徑
docker run --name go-admin -p 8000:8000 -v /config/settings.yml:/config/settings.yml -d go-admin-server

文件產生

bash
go generate

交叉編譯

bash
# windows
env GOOS=windows GOARCH=amd64 go build main.go

# or
# linux
env GOOS=linux GOARCH=amd64 go build main.go

UI 互動端啟動說明

bash
# 安裝 pnpm(若未安裝)
npm install -g pnpm

# 安裝相依套件
pnpm install

# 中國大陸網路可指定鏡像來源加速
pnpm install --registry=https://registry.npmmirror.com

# 啟動服務
pnpm dev

📨 互動

<table> <tr> <td></td> <td></td> <td></td> <td><a href="https://space.bilibili.com/565616721">wenjianzhang</a></td> </tr> <tr> <td>微信</td> <td>公众号🔥🔥🔥</td> <td><a target="_blank" href="https://shang.qq.com/wpa/qunwpa?idkey=0f2bf59f5f2edec6a4550c364242c0641f870aa328e468c4ee4b7dbfb392627b"></a></td> <td>哔哩哔哩🔥🔥🔥</td> </tr> </table>

💎 貢獻者

<span style="margin: 0 5px;" ><a href="https://github.com/wenjianzhang" ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/G-Akiraka" ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/lwnmengjing" ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/bing127" ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/chengxiao" ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/NightFire0307" ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/appleboy" ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/ninstein" ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/kikiyou" ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/horizonzy" ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/Cassuis" ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/hqcchina" ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/nodece" ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/stephenzhang0713" ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/zhouxixi-dev" ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/Jalins" ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/wkf928592" ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/wxxiong6" ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/Silicon-He" ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/GizmoOAO" ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/bestgopher" ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/wxb1207" ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/misakichan" ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/zhuxuyang" ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/mss-boot" ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/AuroraV" ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/Vingurzhou" ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/haimait" ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/zyd" ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/infnan" ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/d1y" ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/qlijin" ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/logtous " ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/stepway " ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/NaturalGao " ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/DemoLiang " ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/jfcg " ></a></span> <span style="margin: 0 5px;" ><a href="https://github.com/Nicole0724 " ></a></span>

JetBrains 開源證書支援

go-admin 專案一直以來都是在 JetBrains 公司旗下的 GoLand 整合開發環境中進行開發,基於 free JetBrains Open Source license(s) 正版免費授權,在此表達我的謝意。

<a href="https://www.jetbrains.com/?from=kubeadm-ha" target="_blank"></a>

🤝 特別感謝

  1. ant-design
  2. ant-design-pro
  3. arco-design
  4. arco-design-pro
  5. gin
  6. casbin
  7. spf13/viper
  8. gorm
  9. gin-swagger
  10. golang-jwt
  11. vue-element-admin
  12. ruoyi-vue
  13. form-generator

🤟 贊助

如果你覺得這個專案幫助到了你,可以幫作者買一杯果汁表示鼓勵 :tropical_drink:

🤝 連結

🔑 License

MIT

Copyright (c) 2026 wenjianzhang