On 4 Aug 2016 12:36 a.m., "T L" <tapir....@gmail.com> wrote:
>
> Often, I need converting a []T to []interface{} to use the []interface as
a variable length parameter.
> But converting a []T for []interface{} in a for loop is neither clean nor
efficient.
>
> So is there a function in standard lib to convert []T to a []interface{}?
>

There is no function and it's not possible to define one in Go.

Define your own function for your specific type or avoid []interface{} if
you can. Usually what you want is to put a []T in an interface{} and use
reflect instead.

-- 
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