@cryptotaxi247 / kubo / commits / 69999bd0a

commands: Allow commands to output pointers to specified type

Matt Bell committed Jan 6, 2015 at 11:35 UTC 69999bd0a7d24c9357f95c22a6ea4a6d615207e2
1 file changed +5 -2
commands/command.go
+5 -2
@@ -114,14 +114,17 @@ func (c *Command) Call(req Request) Response {
114 return res
115 }
116
117 - actualType := reflect.ValueOf(output).Type()
117 + actualType := reflect.TypeOf(output)
118 + if actualType.Kind() == reflect.Ptr {
119 + actualType = actualType.Elem()
120 + }
121
122 // test if output is a channel
123 isChan := actualType.Kind() == reflect.Chan
124
125 // If the command specified an output type, ensure the actual value returned is of that type
126 if cmd.Type != nil && !isChan {
124 - expectedType := reflect.ValueOf(cmd.Type).Type()
127 + expectedType := reflect.TypeOf(cmd.Type)
128
129 if actualType != expectedType {
130 res.SetError(ErrIncorrectType, ErrNormal)