1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-20 02:21:48 +08:00

commands: Fixed panic on nil output value

This commit is contained in:
Matt Bell
2015-01-06 11:54:09 -08:00
parent 6236ef7fdb
commit c2f46b618a

View File

@ -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 {