title: How to prevent to multiple goroutines inserts document in persons collections if already exists person with same name and last name?
body: <p>How to prevent multiple goroutines to insert document in persons collections if already exists person with same name and last name ?</p>
  
  <pre><code>type Person struct {
  
      Id                      bson.ObjectId   `bson:"_id"`
      Name            string          `bson:"name"`
      LastName            string          `bson:"lastName"`
  
  }
  </code></pre>
  
  <p>I am using Mongo with mgo driver for go language.</p>
  
  <p>I try to find before insert if there is a document with same name and last name but I don't think that cover whole case when both goroutines check in same time. I tried ensure index by two fields <code>(name, lastName)</code> but it also didn't help.</p>