mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-22 21:21:43 +08:00
commands: Fixed panic on nil output value
This commit is contained in:
@ -114,13 +114,16 @@ func (c *Command) Call(req Request) Response {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isChan := false
|
||||||
actualType := reflect.TypeOf(output)
|
actualType := reflect.TypeOf(output)
|
||||||
|
if actualType != nil {
|
||||||
if actualType.Kind() == reflect.Ptr {
|
if actualType.Kind() == reflect.Ptr {
|
||||||
actualType = actualType.Elem()
|
actualType = actualType.Elem()
|
||||||
}
|
}
|
||||||
|
|
||||||
// test if output is a channel
|
// test if output is a channel
|
||||||
isChan := actualType.Kind() == reflect.Chan
|
isChan = actualType.Kind() == reflect.Chan
|
||||||
|
}
|
||||||
|
|
||||||
// If the command specified an output type, ensure the actual value returned is of that type
|
// If the command specified an output type, ensure the actual value returned is of that type
|
||||||
if cmd.Type != nil && !isChan {
|
if cmd.Type != nil && !isChan {
|
||||||
|
Reference in New Issue
Block a user