提交 69999bd0 作者: Matt Bell

commands: Allow commands to output pointers to specified type

上级 77e5742a
......@@ -114,14 +114,17 @@ func (c *Command) Call(req Request) Response {
return res
}
actualType := reflect.ValueOf(output).Type()
actualType := reflect.TypeOf(output)
if actualType.Kind() == reflect.Ptr {
actualType = actualType.Elem()
}
// test if output is a channel
isChan := actualType.Kind() == reflect.Chan
// If the command specified an output type, ensure the actual value returned is of that type
if cmd.Type != nil && !isChan {
expectedType := reflect.ValueOf(cmd.Type).Type()
expectedType := reflect.TypeOf(cmd.Type)
if actualType != expectedType {
res.SetError(ErrIncorrectType, ErrNormal)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论