1. 程式人生 > >golang:bson.ObjectId與string轉化

golang:bson.ObjectId與string轉化

string tty str () ola 資料 pri ring cti

網上資料不好搜,記下來:
兩個變量:
id bson.ObjectId
str string

  • bson.ObjectId—>string

     id.Hex()
  • string—>bson.ObjectId

     bson.ObjectIdHex(str)

golang:bson.ObjectId與string轉化