Skip to content

Instantly share code, notes, and snippets.

@dgrijalva
Created September 13, 2012 18:41
Show Gist options
  • Save dgrijalva/3716580 to your computer and use it in GitHub Desktop.
Save dgrijalva/3716580 to your computer and use it in GitHub Desktop.
BSON encoding issues with mgo
package main
import (
"launchpad.net/mgo/v2"
"launchpad.net/mgo/v2/bson"
)
type insertType struct {
Foo bson.ObjectId `bson:"foo,omitempty"`
}
func main() {
conn, _ := mgo.Dial("localhost")
db := conn.DB("test")
coll := db.C("mgotest")
coll.Insert(&insertType{Foo: bson.NewObjectId()})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment