From 69999bd0a7d24c9357f95c22a6ea4a6d615207e2 Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Tue, 6 Jan 2015 11:35:19 -0800 Subject: [PATCH] commands: Allow commands to output pointers to specified type --- commands/command.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/commands/command.go b/commands/command.go index f46fbe324..8536e80e0 100644 --- a/commands/command.go +++ b/commands/command.go @@ -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)