Is it possible to read a function/method parameter type, and its return type?
I've read the docs http://golang.org/pkg/reflect/ but couldn't find
any fuction for this.
Cheers,
Łukasz Gruner
On Sun, 14 Aug 2011 15:27:08 +0200, uki <uka...@gmail.com> wrote:
> Hi,
>
> Is it possible to read a function/method parameter type, and its return type?
> I've read the docs http://golang.org/pkg/reflect/ but couldn't find
> any fuction for this.
once you have the Type of the method or function in hand, you can then
call on of those:
// In returns the type of a function type's i'th input parameter.
// It panics if the type's Kind is not Func.
// It panics if i is not in the range [0, NumIn()).
In(i int) Type
// NumIn returns a function type's input parameter count.
// It panics if the type's Kind is not Func.
NumIn() int
// NumOut returns a function type's output parameter count.
// It panics if the type's Kind is not Func.
NumOut() int
// Out returns the type of a function type's i'th output parameter.
// It panics if the type's Kind is not Func.
// It panics if i is not in the range [0, NumOut()).
Out(i int) Type
hth,
-s