With mongo-go-driver, how do I efficiently retrieve duplicated field name from WriteError?
问题 I have three unique indexes in my collection. When user accidentally insert a data having a duplicate in the field B , how do I know that the duplication comes from field B ? On unique index constraint violation, mongo-go-driver behavior is returning err WriteException , which basically consist of an array of WriteError and some other object. The WriteError itself (from mongo-go-driver) : // WriteError is an error that occurred during the execution of a write operation. This error type is