使用 shell 脚本,快速升级 Casdoor 依赖的 Beego 到 v2 版本
脚本
git clone https://github.com/casdoor/casdoor.git
cd casdoor
git checkout v1.44.5
go get -u github.com/beego/beego/v2
bee fix -t 2
find . -type f -name "*.go" | xargs sed -i '' "s#github.com/beego/beego/v2/adapter/utils/pagination#github.com/beego/beego/v2/server/web/pagination#g"
find . -type f -name "*.go" | xargs sed -i '' "s#github.com/beego/beego/v2/adapter/context#github.com/beego/beego/v2/server/web/context#g"
sed -i '' "s#ctx.Input.CruSession.Get(#ctx.Input.CruSession.Get(nil, #g" routers/base.go
sed -i '' "s#ctx.Input.CruSession.Set(#ctx.Input.CruSession.Set(nil, #g" routers/base.go
sed -i '' "s#ctx.Input.CruSession.SessionRelease(#ctx.Input.CruSession.SessionRelease(nil, #g" routers/base.go
find . -type f -name "*.go" | xargs sed -i '' "s#github.com/casdoor/casdoor#github.com/xiexianbin/iam#g"
sed -i '' "s#github.com/casdoor/casdoor#github.com/xiexianbin/iam#g" go.mod
然后手动处理部分文件,如删除 main.go 中的 adaptor 等。