I have an idea to use interfaces in Go to define RPC style interfaces. So for a given service, I might create an interface like this:
type MyService interface{
You can not create a type with attached methods via reflection, as to instantiate an object of that type.
You could possibly achieve this with a lot of hackery through the unsafe
package. But even then, it'd be a massive pain.
If you elaborated more on the problem you're trying to solve, the community could come up with alternatives ways of solving it.
Edit (23. July 2015): starting with Go 1.5 there's reflect.FuncOf
and reflect.MakeFunc
, which do exactly what you want.