Go版本:1.7
beego版本:1.7.1
Code:
var FilterUser = func(ctx *context.Context) {
_, ok := ctx.Input.Session("uid").(int)
if !ok && ctx.Request.RequestURI != "/login" {
ctx.Redirect(302, "/login")
}
}
Build failed :
controllers/auth.go:56: ctx.Input undefined (type *"context".Context is pointer to interface, not interface)
controllers/auth.go:58: ctx.Redirect undefined (type *"context".Context is pointer to interface, not interface)
I think you miss import the context and github.com/astaxie/beego/context
pycharm auto import the context but not github.com/astaxie/beego/context, it confused me.
beego_context "github.com/astaxie/beego/context"
Most helpful comment
I think you miss import the context and github.com/astaxie/beego/context