Im new in Golang and Im building a Golang CRUD using mgo framework to practice. When I insert one element using mgo, is inserted two times instead of one time, I ckecked it in MongoDB Compass Community. This is my repository
This is a picture showing how is being saved in my database:
Can anybody help me?
Your code inserts a single document only. If it would insert 2, properties (except the _id
field) would be identical / same.
And your 2 documents have different time
field, thus they are from 2 different runs.
So what you see is the result of 2 different runs (2 seconds away from each other), either by you or by your IDE.