How can I convert func add (a, b int) int
to func(...interface{}) interace{}
type ?
Any ideas about implementing generic functions using the reflect package ?
How can I convert func add (a, b int) int
to func(...interface{}) interace{}
type ?
Any ideas about implementing generic functions using the reflect package ?
There is no "casting" is go (well, using the "unsafe" package kind of is like casting).
You cannot convert function types like this, since they have different layouts in memory. Generic-like functions can be made through the reflect package, though with significant overhead. See http://golang.org/pkg/reflect/#example_MakeFunc for an example.
For most use cases of generic functions, you're probably better off accepting an interface, and using type assertions or switches (http://golang.org/ref/spec#Type_switches), rather than the reflection library.