Ah! No, that is not possible, because interfaces (and other types) are not 
first-class objects in Go like they are in some other languages (such as 
Python).  You can work around it, to some extent, by passing a zero-valued 
instance of such an interface (e.g. PrintInterface(A{})) and using some 
reflection magics to do what you need based on the reflect.Type and similar. 
That's how a number of libraries like Resty determine how to e.g. deserialize 
JSON to a specific type requested by users. It's got its warts, but it works.


- Dave


> On Dec 10, 2018, at 9:53 AM, Mark Volkmann <r.mark.volkm...@gmail.com> wrote:
> 
> Yes, this is what I'm trying to do!
> Perhaps this is not possible.
> 
> On Sun, Dec 9, 2018 at 10:34 PM Robert Engels <reng...@ix.netcom.com> wrote:
> I think what the OP wants is:
> 
> type A interface{}
> type B interface{}
> 
> ...
> PrintInterface(A)
> 
> Meaning they want to pass the interface definition to some method. 
> 
> At least that’s what I am guessing. 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to