I was getting an error trying to pass a []string to this elasticsearch API
ctor:
https://github.com/olivere/elastic/blob/v6.2.11/search_queries_terms_set.go#L26

func NewTermsSetQuery(name string, values ...interface{}) *TermsSetQuery

And it was failing with "cannot use vals (type []string) as type
[]interface {}".
See: https://play.golang.org/p/l5pzqyugM29

When I figured out how to satisfy the signature, it reminded me of the
issue others have had with assigning slices of concrete values to slices of
interface values. I get that you can't directly do that because the memory
layout is different. But I was confused as to why this variadic example
can't work as had expected? I guess the variadic ... instead of seeing
[]interface{} in the signature threw off my expectations. I don't really
know whats going on under the hood when a variadic function handles
do(mySlice...).  Is it exactly the same issue as a direct argument mapping
between []string and []interface{} function parameters?

Justin

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