不能使用X(类型func(context *gin. context) bool的值)作为类型gin.参数y 中的Han



我想使用call this function

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

作为参数

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

它给了我这个错误

不能使用x._controller。getttest(类型func(context *gin.Context) bool的值)作为类型杜松子酒。handlerfunction在converterTest的参数中。得到

方法签名与所需的函数签名不匹配。HandlerFunc不返回任何东西。如果您想忽略方法的返回值,您可以编写一个适配器函数:

converterTest.GET("/test", middleware.Auth(), func(c *gin.Context) {
x._controller.GetTest(c)
})

相关内容

最新更新