That _is_ the correct way iff req is not nil. Check your errors first. V.
On Wednesday, 18 March 2020 06:22:07 UTC+1, Alexander Mills wrote: > > > hey all I am trying to read the Response from http.Request like so: > > func (ctr *Controller) Login(c *common.CPContext, req *http.Request, res > http.ResponseWriter) (int, interface{}) { defer func() { > var code = req.Response.StatusCode; // invalid memory address > or nil pointer dereference if code < 400 { > user.LoginAttempts = 0 > } else { > user.LoginAttempts = user.LoginAttempts + 1 > } > _, err := user.Update(ctx, db, boil.Infer()) > if err != nil { > log.Warningf("could not save/update user model: %v", > err) > } }()} > > 10:18 <https://gophers.slack.com/archives/C2J635FSA/p1584508722032100> > I am getting that error: > > `invalid memory address or nil pointer dereference` - > > does anyone know how to read the Response StatusCode from req.Response? > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/aee48e02-044a-4bde-847a-6615ca0bd4be%40googlegroups.com.