I am experiencing some odd behaviour with `inline`When I return the output struct the thing works like a charm, but fails when I pass a reference to the destination object.Am i missing something here ?Code:package mainimport ("log")type Base struct {Id string `bson:"_id" json:"_id"`ValueOn int `bson:"value_on" json:"value_on"`}type User struct {Base ",inline"Firstname string `bson:"first_name" json:"first_name"`}func BsonWithInterface(d interface{}, o interface{}) {b, _ := bson.Marshal(d)bson.Unmarshal(b, &o)}func BsonWithUser(d interface{}, o *User) {b, _ := bson.Marshal(d)bson.Unmarshal(b, &o)}func BsonWithReturn(d interface{}) User {var tmp Userb, _ := bson.Marshal(d)bson.Unmarshal(b, &tmp)return tmp}func main() {var bson_tmp Uservar strict_tmp Userx := User{Base{"1234", 5}, "Jaideep"}BsonWithInterface(x, &bson_tmp)log.Println("func (interface, interface):", bson_tmp.ValueOn, bson_tmp.Id)BsonWithUser(x, &strict_tmp)log.Println("func (interface, user):", bson_tmp.ValueOn, bson_tmp.Id)y := BsonWithReturn(x)log.Println("func (interface) User:", y.ValueOn, y.Id)}Output is2013/05/13 19:44:17 func (interface, interface): 02013/05/13 19:44:17 func (interface, user): 02013/05/13 19:44:17 func (interface) User: 5 1234Instead of2013/05/13 19:44:17 func (interface, interface): 5 12342013/05/13 19:44:17 func (interface, user): 5 12342013/05/13 19:44:17 func (interface) User: 5 1234
And don't ever throw away errors like that! The package would raise the issue.
--
You received this message because you are subscribed to the Google Groups "mgo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mgo-users+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.