In Go, if you create a document whose struct has bson:"_id" ID definition but the value isn’t set, it will contain a zero value (000000000000000000000000). MongoDB will not generate the value because there is already a value set to the ID. You can either:
- Assign value to ID, or
- Update the tag with
bson:"_id,omitempty"
The latter will remove the id field during the encoding process, causing MongoDB to generate a unique value for it.