title: Golang official MongoDB driver ObjectID weird behavior
body: <p>I am trying to use the official mongodb driver in golang and am seeing something unexpected.</p>
  
  <p>If I have a struct like</p>
  
  <pre><code>type User struct {
      ID     primitive.ObjectID `json:"id" bson:"_id"`
      Name   string             `json:"name" bson:"name"`
      Email  string             `json:"email" bson:"email"`
  }
  </code></pre>
  
  <p>I create a new instance of this with <code>Name</code> and <code>Email</code> but omit ID expecting that the DB will fill this with its value. Instead it uses all zeroes and so the second and so on inserts fail with </p>
  
  <pre><code>multiple write errors: [{write errors: [{E11000 duplicate key error collection: collection.name index: _id_ dup key: { : ObjectId('000000000000000000000000') }}]}, {&lt;nil&gt;}]
  </code></pre>
  
  <p>If I use a <code>*primitive.ObjectID</code> I get the same class of error only on <code>null</code> instead of zeroes</p>
  
  <pre><code>multiple write errors: [{write errors: [{E11000 duplicate key error collection: collection.name index: _id_ dup key: { : null }}]}, {&lt;nil&gt;}]
  </code></pre>
  
  <p>It doesn't matter if I use the <code>omitempty</code> directive or not, same result.</p>
  
  <p>If I omit the <code>ID</code> field entirely, it works, but then my struct doesn't have that data on it.</p>
  
  <p>Is there a way to have the DB handle the ID? Or <em>MUST</em> I explicitly call the <code>NewObjectID()</code> function on the struct?</p>