[go-nuts] Re: using interface{} values in C/C++ bindings

2024-04-09 Thread Mihai Barbu
>>yes, Is there any library code in golang that helps me to read out interface{}'s type information? Yes, there is https://golang.org/pkg/reflect For example: getType(0) getType("hello string") func getType(v interface{}){ t := reflect.TypeOf(v) fmt.Printf("type is %s", t) } On Tuesday,

[go-nuts] Is it possible to "extract" the generic [T] from a reflected type ?

2024-04-09 Thread Mihai Barbu
I need to call some generic functions with types that are now known at compile time. Is it possible to do this? See the code below (vastly reduced). // fv is a function that returns an unknown type func Do(fv reflect.Value){ // get the first returned type by function fv vt :=