Go - How to use Explain?

As part of testing/continuous integration, I would like to make sure that every query in my application uses an index. I already have a “wrapper” function for virtually every find query so if in testing mode, before executing the query, I’d like to make sure that there is an index that supports the query. How do I run the explain command? Or are there “server stats” that would show me how many queries were run without an index?

My production dataset is such that queries that don’t have indexes don’t return, so it’s not okay to not have an index for a query.

It is a big subject that is very well covered in course M201: MongoDB Performance at https://university.mongodb.com. You may also start with https://docs.mongodb.com/manual/reference/method/cursor.explain/

Excellent question as the golang driver doesn’t seem to have an Explain method.