Does the ListInsertOp in golang aerospike client support inserting an array of elements ?
If I use https://godoc.org/github.com/aerospike/aerospike-client-go#ListAppendOp, and pass an array ([]string), it just appends the whole array as one value in the list. Am I using it wrong or is there another way to do the same?
ListAppendOp
is a variadic function accepting arbitrary number of arguments of type interface{}
. If you call it passing your array, it will receive a slice of interface{}
([]interface{}
) with a single element which is your array.
You need to convert your array to a slice of interface{}
and expand it using ...
when passing it to the function:
a := []string{"a", "b", "c"}
s := make([]interface{}, len(a))
for i, v := range a {
s[i] = v
}
ListAppendOp("bin1", s...)
Example of passing an array to a variadic function: https://play.golang.org/p/541aJ6dY6D
From the specs: Passing arguments to ... parameters