diff --git a/README.md b/README.md index 9e2d7c15..32213fc0 100644 --- a/README.md +++ b/README.md @@ -223,12 +223,12 @@ zap: #### 2.3.1 安装 swagger -##### (1)可以科学上网 +##### (1)可以访问外国网站 ```` go get -u github.com/swaggo/swag/cmd/swag ```` -##### (2)无法科学上网 +##### (2)无法访问外国网站 由于国内没法安装 go.org/x 包下面的东西,推荐使用 [goproxy.io](https://goproxy.io/zh/) diff --git a/server/service/sys_casbin.go b/server/service/sys_casbin.go index 6e72c5ff..0c0fb340 100644 --- a/server/service/sys_casbin.go +++ b/server/service/sys_casbin.go @@ -5,13 +5,11 @@ import ( "gin-vue-admin/global" "gin-vue-admin/model" "gin-vue-admin/model/request" - "strings" - "sync" - "github.com/casbin/casbin/v2" "github.com/casbin/casbin/v2/util" gormadapter "github.com/casbin/gorm-adapter/v3" _ "github.com/go-sql-driver/mysql" + "strings" ) //@author: [piexlmax](https://github.com/piexlmax) @@ -90,17 +88,10 @@ func ClearCasbin(v int, p ...string) bool { //@description: 持久化到数据库 引入自定义规则 //@return: *casbin.Enforcer -var ( - e *casbin.Enforcer - once sync.Once -) - func Casbin() *casbin.Enforcer { - once.Do(func() { - a, _ := gormadapter.NewAdapterByDB(global.GVA_DB) - e, _ = casbin.NewEnforcer(global.GVA_CONFIG.Casbin.ModelPath, a) - e.AddFunction("ParamsMatch", ParamsMatchFunc) - }) + a, _ := gormadapter.NewAdapterByDB(global.GVA_DB) + e, _ := casbin.NewEnforcer(global.GVA_CONFIG.Casbin.ModelPath, a) + e.AddFunction("ParamsMatch", ParamsMatchFunc) _ = e.LoadPolicy() return e }