import("gopkg.in/mgo.v2""gopkg.in/mgo.v2/bson")//结构体例子type Person struct{
ID bson.ObjectId `bson:"_id,omitempty"`//类型是bson.ObjectId
Name string`bson:"xingming"`//这里变量名和数据库里的名字不一致
Gender int`bson: "xingbie"`
直接先上代码import ( "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson")//结构体例子type Person struct { ID bson.ObjectId `bson:"_id,omitempty"` //类型是bson.ObjectId Name string `bson:"xingming"` //这里变量名和数据...