go-fly
基於GO語言實現的web客服即時通訊與客服管理系統。非常適合給自己的網站增加在線客服功能,代碼簡單也適合學習。
Github地址:https://github.com/taoshihan1991/go-fly
后台管理地址: https://gofly.sopans.com/login 用戶名:kefu2 密碼:123
前台測試地址: https://gofly.sopans.com/
1.使用gin http框架實現restful風格的API和template包的模板語法進行展示界面
2.使用jwt-go配合gin中間件實現無狀態的jwt登陸認證
3.數據庫實現的rbac權限配合gin中間件實現權限控制
4.通過cobra進行命令行參數解析和執行對應的功能
5.使用go modoule解決依賴問題
6.使用swagger實現文檔展示
7.使用go-imap實現郵件的列表展示和讀取
8.使用go-smtp實現發送郵件
9.使用github.com/gorilla/websocket實現即時通訊
10.使用gorm配合mysql實現數據存儲
11.前端使用elementUI和Vue展示界面
11.充分實踐了struct,interface,map,slice,for range,groutine和channel管道等基礎知識
項目預覽
安裝使用
-
先安裝和運行mysql , 創建go-fly數據庫,並導入*.sql創建表結構與數據.
-
基於go module使用
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
在任意目錄 git clone https://github.com/taoshihan1991/go-fly.git
進入go-fly 目錄
在config目錄mysql.json中配置數據庫
{ "Server":"127.0.0.1", "Port":"3306", "Database":"go-fly", "Username":"go-fly", "Password":"go-fly" }
-
源碼運行 go run go-fly.go server port 8081
-
源碼打包 go build go-fly.go 會生成go-fly可以執行文件
-
導入數據庫(會刪除表清空數據) ./go-fly install
-
二進制文件運行
linux: ./go-fly server port 8081
windows: go-fly.exe server port 8081
nginx部署
參考支持https的部署示例 , 注意反向代理的端口號和證書地址
server {
listen 443 ssl http2;
ssl on;
ssl_certificate conf.d/cert/4263285_gofly.sopans.com.pem;
ssl_certificate_key conf.d/cert/4263285_gofly.sopans.com.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
#listen 80;
server_name gofly.sopans.com;
access_log /var/log/nginx/gofly.sopans.com.access.log main;
location / {
proxy_pass http://127.0.0.1:8081;
proxy_http_version 1.1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Origin "";
}
}
server{
listen 80;
server_name gofly.sopans.com;
access_log /var/log/nginx/gofly.sopans.com.access.log main;
location / {
proxy_pass http://127.0.0.1:8081;
proxy_http_version 1.1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Origin "";
}
}
生成文檔
- 需要先安裝swag
- 在根目錄swag init