forked from domodwyer/mgo
-
Notifications
You must be signed in to change notification settings - Fork 228
Open
Labels
Description
Hi
I encountered an issue while populating a struct with db data. My structs are as follows:
type Product struct {
ID bson.ObjectId `json:"id" bson:"_id"`
Name string `json:"name" bson:"name"`
Meta `json:"meta" bson:"meta"`
}
type Meta {
*Printer `json:",inline" bson:",inline"`
*Monitor `json:",inline" bson:",inline"`
}
type Monitor struct {
ScreenSize float64 `json:"screen_size" bson:"screen_size"`
ScreenType string `json:"screen_type" bson:"screen_type"`
}
...
p := Product{}
if err := db.C("products").Find(nil).One(&p); err != nil {
return err
}
the error that I get from this action is
reflect: indirection through nil pointer to embedded struct
I should note that this only happens while reading from the db, and not when inserting into.
I am aware that this issue has been raised couple of times before: #146, go-mgo#346, and although a fix has been submitted, it still seems that it doesn't work properly (at least for reading data from the db).
The version of go that I'm using is
go version go1.10.3 darwin/amd64
and the globalsign/mgo version is the last one available