title: ObjectID automatically set to "0...0" in go with official mongoDB driver
body: <p>I'm trying to save user entries in a MongoDB database with Go. Users should get an ID automatically. I'm using the offical MongoDB Go driver.</p>
  
  <p>My sources were especially <a href="https://vkt.sh/go-mongodb-driver-cookbook/" rel="noreferrer">https://vkt.sh/go-mongodb-driver-cookbook/</a> and <a href="https://www.mongodb.com/blog/post/mongodb-go-driver-tutorial" rel="noreferrer">https://www.mongodb.com/blog/post/mongodb-go-driver-tutorial</a>.</p>
  
  <p>Struct looks like this:</p>
  
  <pre class="lang-golang prettyprint-override"><code>type User struct {
      ID primitive.ObjectID `json:"_id" bson:"_id"`
      Fname string `json:"fname" bson:"fname"`
      Lname string `json:"lname" bson:"lname"`
      Mail string `json:"mail" bson:"mail"`
      Password string `json:"password" bson:"password"`
      Street string `json:"street" bson:"street"`
      Zip string `json:"zip" bson:"zip"`
      City string `json:"city" bson:"city"`
      Country string `json:"country" bson:"country"`
  }
  </code></pre>
  
  <p>Setting up the database (connection works) and signing up users (based on an HTTP-Request <code>r</code> with a user in it's body):</p>
  
  <pre class="lang-golang prettyprint-override"><code>ctx := context.Background()
  uriDB := "someURI"
  clientOptions := options.Client().ApplyURI(uriDB)
  client, err := mongo.Connect(ctx, clientOptions)
  collection := client.Database("guDB").Collection("users")
  
  ...
  
  var user User
  err := json.NewDecoder(r.Body).Decode(&amp;user)
  
  ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
  defer cancel()
  result, err := collection.InsertOne(ctx, user)
  ...
  
  </code></pre>
  
  <p>When I enter the first user, it is added to the collection, but the ID looks like this:
  <code>_id:ObjectID(000000000000000000000000)</code></p>
  
  <p>If I now want to enter another user, I get the following error:</p>
  
  <pre><code>multiple write errors: [{write errors: [{E11000 duplicate key error collection: guDB.users index: _id_ dup key: { : ObjectId('000000000000000000000000') }}]}, {&lt;nil&gt;}]
  </code></pre>
  
  <p>So it seems like again ObjectID <code>000000000000000000000000</code> is assigned.</p>
  
  <p>I expected the ID to be automatically set to a unique value for each entry.</p>
  
  <p>Do I have to manually set the ID or how can I assign unique IDs to users?</p>