How to specify startkey, endkey for composite view query in GO SDK

I have a view with map function like this:

function (doc, meta) {
    emit([doc.status, doc.name], doc.another_field);
}

Here the doc.status is a boolean and doc.name is a string. I get the expected result in the web console when I run the view with this:

startkey = [true,"desired_name"]
endkey = [true,"desired_nameZZ"]

However I was unable to figure out how to specify this in golang SDK. The golang parameter accepts an interface. I tried sending the argument as a string such as “true,desired_name” but its not working. There is nothing in the GO SDK documentation on how to handle situation like this.

Can someone tell me how I can pass composite view key like this in golang?
Any help would be appreciated.

I am using couchbase 3.0.1 Community Edition.

Hey @ahmed.sharif.bd,

In Go, when you need to provide an array of parameters which are varying types, you should use the []interface{} type. So for instance, to specify the keys that you are looking for, you would probably want this:

startKey := []interface{}{ true, "desired_name" }
endKey := []interface{}{ true, "desired_nameZ" }

Cheers, Brett

That worked. Thanks a lot for your answer.

In the meantime I was doing something like this:

startKey := fmt.Sprintf("[%s,\"%s\"]", strconv.FormatBool(true), "desired_name")
endKey := fmt.Sprintf("[%s,\"%s\"]", strconv.FormatBool(true), "desired_nameZ")
vq := gocb.NewViewQuery("design_doc_name", "view_name")
vq = vq.Custom("startkey", startKey)
vq = vq.Custom("endkey", endKey)

Which worked, but the way you showed is much cleaner and less hacky. Thanks again.