Beego: Error : type *"context".Context is pointer to interface, not interface

Created on 7 Nov 2016  ·  3Comments  ·  Source: astaxie/beego

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)

Most helpful comment

I think you miss import the context and github.com/astaxie/beego/context

All 3 comments

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"

Was this page helpful?
0 / 5 - 0 ratings