Skip to main content

casbin使用示例

package main

import (
  	sqlxadapter "github.com/Blank-Xu/sqlx-adapter"
	"github.com/casbin/casbin/v2"
	"github.com/casbin/casbin/v2/model"
	"github.com/casbin/casbin/v2/persist"
    "github.com/jmoiron/sqlx"
    _ "github.com/glebarez/sqlite"
)

func main(){
  	db, err := sqlx.Connect("sqlite", "file:./public/data.db?cache=shared")
	if err != nil {
		return
	}
	adapter, err := sqlxadapter.NewAdapter(db, "casbin_rule")
	if err != nil {
		return
	}
}