0

I want to use call this func

func (x *Controller) GetTest(context *gin.Context) boolean {
  ...
  return true;
}

as an argument here

    converterTest.GET("/test", middleware.Auth(), x._controller.GetTest)

It gives me this error

cannot use x._controller.GetTest (value of type func(context *gin.Context) bool) as type gin.HandlerFunc in argument to converterTest.GET

BenDou
  • 13
  • 2

1 Answers1

-1

The method signature does not match the required function signature. HandlerFunc's do not return anything. If you want to ignore the return value of the method, you can write an adapter function:

converterTest.GET("/test", middleware.Auth(), func(c *gin.Context) {
   x._controller.GetTest(c)
})
Burak Serdar
  • 46,455
  • 3
  • 40
  • 59