提交 c2f46b61 作者: Matt Bell

commands: Fixed panic on nil output value

上级 6236ef7f
......@@ -114,13 +114,16 @@ func (c *Command) Call(req Request) Response {
return res
}
isChan := false
actualType := reflect.TypeOf(output)
if actualType.Kind() == reflect.Ptr {
actualType = actualType.Elem()
}
if actualType != nil {
if actualType.Kind() == reflect.Ptr {
actualType = actualType.Elem()
}
// test if output is a channel
isChan := actualType.Kind() == reflect.Chan
// 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 {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论