I want to retrieve list of ids (type long) from the mongo collection
ids: = [] int64
if count >= 5 {
err = collection.Find(query).Select(bson.M {
"_id": 1
}).Skip(rand.Intn(count - 4)).Limit(4).All(ids)
}
I get an error stating http: panic serving [::1]:62322: result argument must be a slice address
I tried using make for getting the slice, which resulted in the same error
ids: = make([]int64, 0, 4)
if count >= 5 {
err = collection.Find(query).Select(bson.M {
"_id": 1
}).Skip(rand.Intn(count - 4)).Limit(4).All(ids)
}