I am using mongo-driver from go.mongodb.org/mongo-driver. I already converted primitive.ObjectID to string Using this link Primitive.ObjectID to string
Now i need to convert string to primitive.ObjectID
I am using mongo-driver from go.mongodb.org/mongo-driver. I already converted primitive.ObjectID to string Using this link Primitive.ObjectID to string
Now i need to convert string to primitive.ObjectID
Copyright © 2021 Jogjafile Inc.
The linked answer uses ObjectID.Hex() to obtain a string of the hexadecimal representation of the ObjectID.
The very same API docs have a ObjectIDFromHex function to do the reverse:
Use it as follows:
Quick reminder: always read the docs of the libraries you are using.