If documents are stored with line identifiers, the code looks correct.
IDs look like identifiers for hex encoded objects. If the object identifiers are object identifiers, you need to convert the hexadecimal strings to the object identifiers:
oids := make([]bson.ObjectId, len(ids))
for i := range ids {
oids[i] = bson.ObjectIdHex(ids[i])
}
query := bson.M{"_id": bson.M{"$in": oids}}
source
share