且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

不能使用函数(func()类型)作为参数中的类型

更新时间:2022-11-21 15:42:03

您正确地将函数作为参数传递,但是它们与预期的签名不匹配.将您的功能更改为:

You are passing the function as an argument correctly but they do not match the expected signature. Change your functions to:

func UpperCaseHandler(md busboy.MessageDelivery) (interface{}, error} {
     s.Reply(MessageTest{strings.ToUpper(md.Message.(string))}, md.Delivery)
     return nil, nil
}

func RepeatHandler(md busboy.MessageDelivery) (interface{}, error} {
     s.Reply(MessageTest{strings.Repeat(md.Message.(string), 5)}, md.Delivery)
     return nil, nil
}