This is am example how to use mongo transaction in golang. Before we code, we need build mongo replica set.Because the mongo transaction is base the replica set.
I think you can find the answer from Google.
we should import mongo-driver for golang
go get -u go.mongodb.org/mongo-driver